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