11
11
namespace Symfony \Component \Workflow \Tests \Dumper ;
12
12
13
13
use PHPUnit \Framework \TestCase ;
14
- use Symfony \Component \Workflow \Dumper \DumperInterface ;
15
14
use Symfony \Component \Workflow \Dumper \PlantUmlDumper ;
16
15
use Symfony \Component \Workflow \Marking ;
17
16
use Symfony \Component \Workflow \Tests \WorkflowBuilderTrait ;
@@ -21,73 +20,46 @@ class PlantUmlDumperTest extends TestCase
21
20
use WorkflowBuilderTrait;
22
21
23
22
/**
24
- * @var DumperInterface[]
23
+ * @dataProvider provideWorkflowDefinitionWithoutMarking
25
24
*/
26
- private $ dumpers ;
27
-
28
- protected function setUp ()
25
+ public function testDumpWorkflowWithoutMarking ($ definition , $ marking , $ expectedFileName , $ title )
29
26
{
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 );
35
33
}
36
34
37
- /**
38
- * @dataProvider provideWorkflowDefinitionWithoutMarking
39
- */
40
- public function testDumpWithoutMarking ($ definition , $ expectedFileName , $ title , $ nofooter )
35
+ public function provideWorkflowDefinitionWithoutMarking ()
41
36
{
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 ' );
48
43
}
49
44
50
45
/**
51
- * @dataProvider provideWorkflowDefinitionWithMarking
46
+ * @dataProvider provideStateMachineDefinitionWithoutMarking
52
47
*/
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 )
64
49
{
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 );
71
56
}
72
57
73
- public function provideWorkflowDefinitionWithMarking ()
58
+ public function provideStateMachineDefinitionWithoutMarking ()
74
59
{
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 ' );
84
61
$ 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 ' );
91
63
}
92
64
93
65
private function getFixturePath ($ name , $ transitionType )
0 commit comments