PropertyMetadataTest.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Metadata\Tests;
  3. use Metadata\Tests\Fixtures\TestObject;
  4. use Metadata\PropertyMetadata;
  5. class PropertyMetadataTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testConstructor()
  8. {
  9. $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
  10. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class);
  11. $this->assertEquals('foo', $metadata->name);
  12. $this->assertEquals(new \ReflectionProperty('Metadata\Tests\Fixtures\TestObject', 'foo'), $metadata->reflection);
  13. }
  14. public function testSerializeUnserialize()
  15. {
  16. $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
  17. $this->assertEquals($metadata, unserialize(serialize($metadata)));
  18. }
  19. public function testSetGetValue()
  20. {
  21. $obj = new TestObject();
  22. $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
  23. $this->assertNull($metadata->getValue($obj));
  24. $metadata->setValue($obj, 'foo');
  25. $this->assertEquals('foo', $metadata->getValue($obj));
  26. }
  27. }