public function testLoadClassMetadataAndMerge() { $classMetadata = new ClassMetadata('Symfony\\Component\\Serializer\\Tests\\Fixtures\\GroupDummy'); $parentClassMetadata = new ClassMetadata('Symfony\\Component\\Serializer\\Tests\\Fixtures\\GroupDummyParent'); $this->loader->loadClassMetadata($parentClassMetadata); $classMetadata->merge($parentClassMetadata); $this->loader->loadClassMetadata($classMetadata); $this->assertEquals(TestClassMetadataFactory::createClassMetadata(true), $classMetadata); }
public function testMerge() { $classMetadata1 = new ClassMetadata('c1'); $classMetadata2 = new ClassMetadata('c2'); $ac1 = $this->getMock('Symfony\\Component\\Serializer\\Mapping\\AttributeMetadataInterface'); $ac1->method('getName')->willReturn('a1'); $ac1->method('getGroups')->willReturn(array('a', 'b')); $ac2 = $this->getMock('Symfony\\Component\\Serializer\\Mapping\\AttributeMetadataInterface'); $ac2->method('getName')->willReturn('a1'); $ac2->method('getGroups')->willReturn(array('b', 'c')); $classMetadata1->addAttributeMetadata($ac1); $classMetadata2->addAttributeMetadata($ac2); $classMetadata1->merge($classMetadata2); $ac1->method('getGroups')->willReturn('a', 'b', 'c'); $this->assertEquals(array('a1' => $ac1), $classMetadata2->getAttributesMetadata()); }