MergeableClassMetadataTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Metadata\Tests;
  3. use Metadata\MergeableClassMetadata;
  4. class MergeableClassMetadataTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testMerge()
  7. {
  8. $parentMetadata = new MergeableClassMetadata('Metadata\Tests\Fixtures\TestParent');
  9. $parentMetadata->propertyMetadata['foo'] = 'bar';
  10. $parentMetadata->propertyMetadata['baz'] = 'baz';
  11. $parentMetadata->methodMetadata['foo'] = 'bar';
  12. $parentMetadata->createdAt = 2;
  13. $parentMetadata->fileResources[] = 'foo';
  14. $childMetadata = new MergeableClassMetadata('Metadata\Tests\Fixtures\TestObject');
  15. $childMetadata->propertyMetadata['foo'] = 'baz';
  16. $childMetadata->methodMetadata['foo'] = 'baz';
  17. $childMetadata->createdAt = 1;
  18. $childMetadata->fileResources[] = 'bar';
  19. $parentMetadata->merge($childMetadata);
  20. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $parentMetadata->name);
  21. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $parentMetadata->reflection->name);
  22. $this->assertEquals(array('foo' => 'baz', 'baz' => 'baz',), $parentMetadata->propertyMetadata);
  23. $this->assertEquals(array('foo' => 'baz',), $parentMetadata->methodMetadata);
  24. $this->assertEquals(1, $parentMetadata->createdAt);
  25. $this->assertEquals(array('foo', 'bar'), $parentMetadata->fileResources);
  26. }
  27. }