Skip to content

Commit

Permalink
Test refactored with dataProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Nono1971 authored and Gianluca Arbezzano committed Sep 3, 2015
1 parent d204a7e commit f148ac2
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions tests/DoctrineORMModuleTest/Yuml/MetadataGrapherTest.php
Expand Up @@ -403,8 +403,23 @@ function ($assoc) {

/**
* @covers \DoctrineORMModule\Yuml\MetadataGrapher
* @dataProvider injectMultipleRelationsWithBothBiAndMonoDirectional
*/
public function testBugTestCaseFix()
public function testDrawMultipleClassRelatedBothBiAndMonoDirectional($class1, $class2, $class3, $expected)
{
$this->assertSame(
$expected,
$this->grapher->generateFromMetadata(array($class1, $class2,$class3))
);
}

/**
* dataProvider to inject classes in every order possible into the test
* testDrawMultipleClassRelatedBothBiAndMonoDirectional
*
* @return array
*/
public function injectMultipleRelationsWithBothBiAndMonoDirectional()
{
$class1 = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
$class1->expects($this->any())->method('getName')->will($this->returnValue('A'));
Expand Down Expand Up @@ -434,29 +449,13 @@ public function testBugTestCaseFix()
$class3->expects($this->any())->method('isCollectionValuedAssociation')->will($this->returnValue(true));
$class3->expects($this->any())->method('getFieldNames')->will($this->returnValue(array()));

$this->assertSame(
'[A]-c 1>[C],[B]<>b *-c 1>[C]',
$this->grapher->generateFromMetadata(array($class1, $class2,$class3))
);
$this->assertSame(
'[A]-c 1>[C],[C]<c 1-b *<>[B]',
$this->grapher->generateFromMetadata(array($class1, $class3,$class2))
);
$this->assertSame(
'[B]<>b *-c 1>[C],[A]-c 1>[C]',
$this->grapher->generateFromMetadata(array($class2, $class1,$class3))
);
$this->assertSame(
'[B]<>b *-c 1>[C],[A]-c 1>[C]',
$this->grapher->generateFromMetadata(array($class2, $class3,$class1))
);
$this->assertSame(
'[C]<c 1-b *<>[B],[A]-c 1>[C]',
$this->grapher->generateFromMetadata(array($class3, $class1,$class2))
);
$this->assertSame(
'[C]<c 1-b *<>[B],[A]-c 1>[C]',
$this->grapher->generateFromMetadata(array($class3, $class2,$class1))
return array(
array($class1, $class2, $class3, '[A]-c 1>[C],[B]<>b *-c 1>[C]'),
array($class1, $class3, $class2, '[A]-c 1>[C],[C]<c 1-b *<>[B]'),
array($class2, $class1, $class3, '[B]<>b *-c 1>[C],[A]-c 1>[C]'),
array($class2, $class3, $class1, '[B]<>b *-c 1>[C],[A]-c 1>[C]'),
array($class3, $class1, $class2, '[C]<c 1-b *<>[B],[A]-c 1>[C]'),
array($class3, $class2, $class1, '[C]<c 1-b *<>[B],[A]-c 1>[C]')
);
}

Expand Down

0 comments on commit f148ac2

Please sign in to comment.