1111namespace Symfony \Component \Workflow \Tests \Dumper ;
1212
1313use PHPUnit \Framework \TestCase ;
14- use Symfony \Component \Workflow \Dumper \DumperInterface ;
1514use Symfony \Component \Workflow \Dumper \PlantUmlDumper ;
1615use Symfony \Component \Workflow \Marking ;
1716use Symfony \Component \Workflow \Tests \WorkflowBuilderTrait ;
@@ -21,73 +20,46 @@ class PlantUmlDumperTest extends TestCase
2120 use WorkflowBuilderTrait;
2221
2322 /**
24- * @var DumperInterface[]
23+ * @dataProvider provideWorkflowDefinitionWithoutMarking
2524 */
26- private $ dumpers ;
27-
28- protected function setUp ()
25+ public function testDumpWorkflowWithoutMarking ($ definition , $ marking , $ expectedFileName , $ title )
2926 {
30- $ this ->dumpers =
31- array (
32- PlantUmlDumper::STATEMACHINE_TRANSITION => new PlantUmlDumper (PlantUmlDumper::STATEMACHINE_TRANSITION ),
33- PlantUmlDumper::WORKFLOW_TRANSITION => new PlantUmlDumper (PlantUmlDumper::WORKFLOW_TRANSITION ),
34- );
27+ $ dumper = new PlantUmlDumper (PlantUmlDumper::WORKFLOW_TRANSITION );
28+ $ dump = $ dumper ->dump ($ definition , $ marking , array ('title ' => $ title ));
29+ // handle windows, and avoid to create more fixtures
30+ $ dump = str_replace (PHP_EOL , "\n" , $ dump .PHP_EOL );
31+ $ file = $ this ->getFixturePath ($ expectedFileName , PlantUmlDumper::WORKFLOW_TRANSITION );
32+ $ this ->assertStringEqualsFile ($ file , $ dump );
3533 }
3634
37- /**
38- * @dataProvider provideWorkflowDefinitionWithoutMarking
39- */
40- public function testDumpWithoutMarking ($ definition , $ expectedFileName , $ title , $ nofooter )
35+ public function provideWorkflowDefinitionWithoutMarking ()
4136 {
42- foreach ($ this ->dumpers as $ transitionType => $ dumper ) {
43- $ dump = $ dumper -> dump ( $ definition , null , array ( ' title ' => $ title , 'nofooter ' => $ nofooter ) );
44- // handle windows, and avoid to create more fixtures
45- $ dump = str_replace ( PHP_EOL , "\n" , $ dump . PHP_EOL );
46- $ this -> assertStringEqualsFile ( $ this -> getFixturePath ( $ expectedFileName , $ transitionType ), $ dump );
47- }
37+ yield array ($ this ->createSimpleWorkflowDefinition (), null , ' simple-workflow-nomarking ' , ' SimpleDiagram ' );
38+ yield array ( $ this -> createComplexWorkflowDefinition () , null , ' complex-workflow-nomarking ' , 'ComplexDiagram ' );
39+ $ marking = new Marking ( array ( ' b ' => 1 ));
40+ yield array ( $ this -> createSimpleWorkflowDefinition (), $ marking , ' simple-workflow-marking ' , ' SimpleDiagram ' );
41+ $ marking = new Marking ( array ( ' c ' => 1 , ' e ' => 1 ) );
42+ yield array ( $ this -> createComplexWorkflowDefinition (), $ marking , ' complex-workflow-marking ' , ' ComplexDiagram ' );
4843 }
4944
5045 /**
51- * @dataProvider provideWorkflowDefinitionWithMarking
46+ * @dataProvider provideStateMachineDefinitionWithoutMarking
5247 */
53- public function testDumpWithMarking ($ definition , $ marking , $ expectedFileName , $ title , $ footer )
54- {
55- foreach ($ this ->dumpers as $ transitionType => $ dumper ) {
56- $ dump = $ dumper ->dump ($ definition , $ marking , array ('title ' => $ title , 'nofooter ' => $ footer ));
57- // handle windows, and avoid to create more fixtures
58- $ dump = str_replace (PHP_EOL , "\n" , $ dump .PHP_EOL );
59- $ this ->assertStringEqualsFile ($ this ->getFixturePath ($ expectedFileName , $ transitionType ), $ dump );
60- }
61- }
62-
63- public function provideWorkflowDefinitionWithoutMarking ()
48+ public function testDumpStateMachineWithoutMarking ($ definition , $ marking , $ expectedFileName , $ title )
6449 {
65- $ title = ' SimpleDiagram ' ;
66- yield array ( $ this -> createSimpleWorkflowDefinition (), ' simple-workflow-nomarking-nofooter ' , $ title, true );
67- yield array ( $ this -> createSimpleWorkflowDefinition (), ' simple-workflow-nomarking ' , $ title , false );
68- $ title = ' ComplexDiagram ' ;
69- yield array ( $ this ->createComplexWorkflowDefinition (), ' complex-workflow-nomarking-nofooter ' , $ title , true );
70- yield array ( $ this ->createComplexWorkflowDefinition (), ' complex-workflow-nomarking ' , $ title , false );
50+ $ dumper = new PlantUmlDumper (PlantUmlDumper:: STATEMACHINE_TRANSITION ) ;
51+ $ dump = $ dumper -> dump ( $ definition , $ marking , array ( ' title ' => $ title) );
52+ // handle windows, and avoid to create more fixtures
53+ $ dump = str_replace ( PHP_EOL , "\n" , $ dump . PHP_EOL ) ;
54+ $ file = $ this ->getFixturePath ( $ expectedFileName , PlantUmlDumper:: STATEMACHINE_TRANSITION );
55+ $ this ->assertStringEqualsFile ( $ file , $ dump );
7156 }
7257
73- public function provideWorkflowDefinitionWithMarking ()
58+ public function provideStateMachineDefinitionWithoutMarking ()
7459 {
75- $ title = 'SimpleDiagram ' ;
76- $ marking = new Marking (array ('b ' => 1 ));
77- yield array (
78- $ this ->createSimpleWorkflowDefinition (), $ marking , 'simple-workflow-marking-nofooter ' , $ title , true ,
79- );
80- yield array (
81- $ this ->createSimpleWorkflowDefinition (), $ marking , 'simple-workflow-marking ' , $ title , false ,
82- );
83- $ title = 'ComplexDiagram ' ;
60+ yield array ($ this ->createComplexStateMachineDefinition (), null , 'complex-state-machine-nomarking ' , 'SimpleDiagram ' );
8461 $ marking = new Marking (array ('c ' => 1 , 'e ' => 1 ));
85- yield array (
86- $ this ->createComplexWorkflowDefinition (), $ marking , 'complex-workflow-marking-nofooter ' , $ title , true ,
87- );
88- yield array (
89- $ this ->createComplexWorkflowDefinition (), $ marking , 'complex-workflow-marking ' , $ title , false ,
90- );
62+ yield array ($ this ->createComplexStateMachineDefinition (), $ marking , 'complex-state-machine-marking ' , 'SimpleDiagram ' );
9163 }
9264
9365 private function getFixturePath ($ name , $ transitionType )
0 commit comments