PropertyMetadataTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. $expectedReflector = new \ReflectionProperty('Metadata\Tests\Fixtures\TestObject', 'foo');
  11. $expectedReflector->setAccessible(true);
  12. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class);
  13. $this->assertEquals('foo', $metadata->name);
  14. $this->assertEquals($expectedReflector, $metadata->reflection);
  15. }
  16. public function testSerializeUnserialize()
  17. {
  18. $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
  19. $this->assertEquals($metadata, unserialize(serialize($metadata)));
  20. }
  21. public function testSetGetValue()
  22. {
  23. $obj = new TestObject();
  24. $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
  25. $this->assertNull($metadata->getValue($obj));
  26. $metadata->setValue($obj, 'foo');
  27. $this->assertEquals('foo', $metadata->getValue($obj));
  28. }
  29. }