1<?php 2 3declare(strict_types=1); 4 5namespace Metadata\Tests; 6 7use Metadata\ClassMetadata; 8use PHPUnit\Framework\TestCase; 9 10class ClassMetadataTest extends TestCase 11{ 12 public function testConstructor() 13 { 14 $metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'); 15 16 $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->name); 17 } 18 19 public function testSerializeUnserialize() 20 { 21 $metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'); 22 23 $this->assertEquals($metadata, unserialize(serialize($metadata))); 24 } 25 26 public function testIsFresh() 27 { 28 $ref = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject'); 29 touch($ref->getFilename()); 30 sleep(2); 31 32 $metadata = new ClassMetadata($ref->name); 33 $metadata->fileResources[] = $ref->getFilename(); 34 $this->assertTrue($metadata->isFresh()); 35 36 sleep(2); 37 clearstatcache(!!$ref->getFilename()); 38 touch($ref->getFilename()); 39 $this->assertFalse($metadata->isFresh()); 40 } 41} 42