ClassMetadataTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Metadata\Tests;
  3. use Metadata\ClassMetadata;
  4. class ClassMetadataTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testConstructor()
  7. {
  8. $metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject');
  9. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->name);
  10. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->reflection->name);
  11. }
  12. public function testSerializeUnserialize()
  13. {
  14. $metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject');
  15. $this->assertEquals($metadata, unserialize(serialize($metadata)));
  16. }
  17. public function testIsFresh()
  18. {
  19. $ref = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject');
  20. touch($ref->getFilename());
  21. sleep(2);
  22. $metadata = new ClassMetadata($ref->name);
  23. $metadata->fileResources[] = $ref->getFilename();
  24. $this->assertTrue($metadata->isFresh());
  25. sleep(2);
  26. clearstatcache($ref->getFilename());
  27. touch($ref->getFilename());
  28. $this->assertFalse($metadata->isFresh());
  29. }
  30. }