9
9
10
10
class GraphvizDumperTest extends \PHPUnit_Framework_TestCase
11
11
{
12
+ /**
13
+ * @var GraphvizDumper
14
+ */
12
15
private $ dumper ;
13
16
14
17
public function setUp ()
@@ -36,6 +39,16 @@ public function testWorkflowWithMarking($definition, $marking, $expected)
36
39
$ this ->assertEquals ($ expected , $ dump );
37
40
}
38
41
42
+ /**
43
+ * @dataProvider provideStateMachineDefinition
44
+ */
45
+ public function testStateMachine ($ definition , $ expected )
46
+ {
47
+ $ dump = $ this ->dumper ->dump ($ definition );
48
+
49
+ $ this ->assertEquals ($ expected , $ dump );
50
+ }
51
+
39
52
public function provideWorkflowDefinitionWithMarking ()
40
53
{
41
54
yield array (
@@ -57,6 +70,11 @@ public function provideWorkflowDefinitionWithoutMarking()
57
70
yield array ($ this ->provideSimpleWorkflowDefinition (), $ this ->provideSimpleWorkflowDumpWithoutMarking ());
58
71
}
59
72
73
+ public function provideStateMachineDefinition ()
74
+ {
75
+ yield array ($ this ->provideComplexStateMachineDefinition (), $ this ->provideComplexStateMachineDump ());
76
+ }
77
+
60
78
public function provideComplexWorkflowDefinition ()
61
79
{
62
80
$ builder = new DefinitionBuilder ();
@@ -85,6 +103,25 @@ public function provideSimpleWorkflowDefinition()
85
103
return $ builder ->build ();
86
104
}
87
105
106
+ public function provideComplexStateMachineDefinition ()
107
+ {
108
+ $ builder = new DefinitionBuilder ();
109
+
110
+ $ builder ->addPlaces (range ('a ' , 'g ' ));
111
+
112
+ $ builder ->addTransition (new Transition ('t1 ' , 'a ' , 'c ' ));
113
+ $ builder ->addTransition (new Transition ('t1 ' , 'b ' , 'c ' ));
114
+ $ builder ->addTransition (new Transition ('t2 ' , 'c ' , 'd ' ));
115
+ $ builder ->addTransition (new Transition ('t2 ' , 'e ' , 'd ' ));
116
+ $ builder ->addTransition (new Transition ('t2 ' , 'f ' , 'd ' ));
117
+ $ builder ->addTransition (new Transition ('t3 ' , 'd ' , 'g ' ));
118
+ $ builder ->addTransition (new Transition ('t4 ' , 'f ' , 'e ' ));
119
+ $ builder ->addTransition (new Transition ('t4 ' , 'g ' , 'e ' ));
120
+ $ builder ->addTransition (new Transition ('t5 ' , 'f ' , 'b ' ));
121
+
122
+ return $ builder ->build ();
123
+ }
124
+
88
125
public function createComplexWorkflowDumpWithMarking ()
89
126
{
90
127
return 'digraph workflow {
@@ -198,6 +235,43 @@ public function provideSimpleWorkflowDumpWithoutMarking()
198
235
place_b -> transition_t2 [style="solid"];
199
236
transition_t2 -> place_c [style="solid"];
200
237
}
238
+ ' ;
239
+ }
240
+
241
+ public function provideComplexStateMachineDump ()
242
+ {
243
+ return 'digraph workflow {
244
+ ratio="compress" rankdir="LR"
245
+ node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="1" width="1"];
246
+ edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"];
247
+
248
+ place_a [label="a", shape=circle, style="filled"];
249
+ place_b [label="b", shape=circle];
250
+ place_c [label="c", shape=circle];
251
+ place_d [label="d", shape=circle];
252
+ place_e [label="e", shape=circle];
253
+ place_f [label="f", shape=circle];
254
+ place_g [label="g", shape=circle];
255
+ transition_t1 [label="t1", shape=box, shape="box", regular="1"];
256
+ transition_t2 [label="t2", shape=box, shape="box", regular="1"];
257
+ transition_t3 [label="t3", shape=box, shape="box", regular="1"];
258
+ transition_t4 [label="t4", shape=box, shape="box", regular="1"];
259
+ transition_t5 [label="t5", shape=box, shape="box", regular="1"];
260
+ place_a -> transition_t1 [style="solid"];
261
+ transition_t1 -> place_c [style="solid"];
262
+ place_b -> transition_t1 [style="solid"];
263
+ place_c -> transition_t2 [style="solid"];
264
+ transition_t2 -> place_d [style="solid"];
265
+ place_e -> transition_t2 [style="solid"];
266
+ place_f -> transition_t2 [style="solid"];
267
+ place_d -> transition_t3 [style="solid"];
268
+ transition_t3 -> place_g [style="solid"];
269
+ place_f -> transition_t4 [style="solid"];
270
+ transition_t4 -> place_e [style="solid"];
271
+ place_g -> transition_t4 [style="solid"];
272
+ place_f -> transition_t5 [style="solid"];
273
+ transition_t5 -> place_b [style="solid"];
274
+ }
201
275
' ;
202
276
}
203
277
}
0 commit comments