/** * @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawInheritedAssociations() { $class1 = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata'); $class2 = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata'); $class3 = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata'); $class4 = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata'); $child = get_class($this->getMock('stdClass')); $class1->expects($this->any())->method('getName')->will($this->returnValue('stdClass')); $class1->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array('a'))); $class1->expects($this->any())->method('getAssociationTargetClass')->will($this->returnValue('A')); $class1->expects($this->any())->method('isAssociationInverseSide')->will($this->returnValue(false)); $class1->expects($this->any())->method('isCollectionValuedAssociation')->will($this->returnValue(true)); $class1->expects($this->any())->method('getFieldNames')->will($this->returnValue(array())); $class2->expects($this->any())->method('getName')->will($this->returnValue($child)); $class2->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array('a', 'b'))); $class2->expects($this->any())->method('getAssociationTargetClass')->will($this->returnCallback(function ($assoc) { return strtoupper($assoc); })); $class2->expects($this->any())->method('isAssociationInverseSide')->will($this->returnValue(false)); $class2->expects($this->any())->method('isCollectionValuedAssociation')->will($this->returnValue(true)); $class2->expects($this->any())->method('getFieldNames')->will($this->returnValue(array())); $class3->expects($this->any())->method('getName')->will($this->returnValue('A')); $class3->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array())); $class3->expects($this->any())->method('getFieldNames')->will($this->returnValue(array())); $class4->expects($this->any())->method('getName')->will($this->returnValue('B')); $class4->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array())); $class4->expects($this->any())->method('getFieldNames')->will($this->returnValue(array())); $childName = str_replace('\\', '.', $child); $this->assertSame('[stdClass]<>-a *>[A],[stdClass]^[' . $childName . '],[' . $childName . ']<>-b *>[B]', $this->grapher->generateFromMetadata(array($class1, $class2))); }
/** * @covers \DoctrineORMModule\Yuml\MetadataGrapher * @dataProvider injectMultipleRelationsWithBothBiAndMonoDirectional */ public function testDrawMultipleClassRelatedBothBiAndMonoDirectional($class1, $class2, $class3, $expected) { $this->assertSame($expected, $this->grapher->generateFromMetadata(array($class1, $class2, $class3))); }