kekrozsak/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/ClassMetadataTest.php
2012-07-23 17:09:03 +02:00

39 lines
1.1 KiB
PHP

<?php
namespace Metadata\Tests;
use Metadata\ClassMetadata;
class ClassMetadataTest extends \PHPUnit_Framework_TestCase
{
public function testConstructor()
{
$metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject');
$this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->name);
$this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->reflection->getName());
}
public function testSerializeUnserialize()
{
$metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject');
$this->assertEquals($metadata, unserialize(serialize($metadata)));
}
public function testIsFresh()
{
$ref = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject');
touch($ref->getFilename());
sleep(2);
$metadata = new ClassMetadata($ref->getName());
$metadata->fileResources[] = $ref->getFilename();
$this->assertTrue($metadata->isFresh());
sleep(2);
clearstatcache($ref->getFilename());
touch($ref->getFilename());
$this->assertFalse($metadata->isFresh());
}
}