|
8 | 8 | use loophp\phptree\Node\AttributeNode;
|
9 | 9 | use loophp\phptree\Node\ValueNode;
|
10 | 10 | use PhpSpec\ObjectBehavior;
|
| 11 | +use const PHP_EOL; |
11 | 12 |
|
12 | 13 | class GvSpec extends ObjectBehavior
|
13 | 14 | {
|
@@ -54,52 +55,60 @@ public function it_can_export_to_dot_gv(): void
|
54 | 55 | 'value' => $child4->getValue(),
|
55 | 56 | ];
|
56 | 57 |
|
57 |
| - $result = <<<EOF |
58 |
| -digraph PHPTreeGraph { |
59 |
| -// The graph attributes. |
60 |
| - ratio = fill |
61 |
| - node [style="filled"] |
| 58 | + $result = implode( |
| 59 | + PHP_EOL, |
| 60 | + [ |
| 61 | + 'digraph PHPTreeGraph {', |
| 62 | + '// The graph attributes.', |
| 63 | + ' ratio = fill', |
| 64 | + ' node [style="filled"]', |
| 65 | + '', |
| 66 | + '// The graph nodes.', |
| 67 | + " \"{$nodes['root']['hash']}\" [label=\"{$nodes['root']['value']}\"]", |
| 68 | + " \"{$nodes['child1']['hash']}\" [label=\"{$nodes['child1']['value']}\"]", |
| 69 | + " \"{$nodes['child4']['hash']}\" [label=\"{$nodes['child4']['value']}\"]", |
| 70 | + " \"{$nodes['child2']['hash']}\" [label=\"{$nodes['child2']['value']}\"]", |
| 71 | + " \"{$nodes['child3']['hash']}\" [label=\"{$nodes['child3']['value']}\"]", |
| 72 | + '', |
| 73 | + '// The graph edges.', |
| 74 | + " \"{$nodes['root']['hash']}\" -> \"{$nodes['child1']['hash']}\";", |
| 75 | + " \"{$nodes['child1']['hash']}\" -> \"{$nodes['child4']['hash']}\";", |
| 76 | + " \"{$nodes['root']['hash']}\" -> \"{$nodes['child2']['hash']}\";", |
| 77 | + " \"{$nodes['root']['hash']}\" -> \"{$nodes['child3']['hash']}\";", |
| 78 | + '}', |
| 79 | + ] |
| 80 | + ); |
62 | 81 |
|
63 |
| -// The graph nodes. |
64 |
| - "{$nodes['root']['hash']}" [label="{$nodes['root']['value']}"] |
65 |
| - "{$nodes['child1']['hash']}" [label="{$nodes['child1']['value']}"] |
66 |
| - "{$nodes['child4']['hash']}" [label="{$nodes['child4']['value']}"] |
67 |
| - "{$nodes['child2']['hash']}" [label="{$nodes['child2']['value']}"] |
68 |
| - "{$nodes['child3']['hash']}" [label="{$nodes['child3']['value']}"] |
69 |
| -
|
70 |
| -// The graph edges. |
71 |
| - "{$nodes['root']['hash']}" -> "{$nodes['child1']['hash']}"; |
72 |
| - "{$nodes['child1']['hash']}" -> "{$nodes['child4']['hash']}"; |
73 |
| - "{$nodes['root']['hash']}" -> "{$nodes['child2']['hash']}"; |
74 |
| - "{$nodes['root']['hash']}" -> "{$nodes['child3']['hash']}"; |
75 |
| -} |
76 |
| -EOF; |
77 | 82 | $this
|
78 | 83 | ->export($tree)
|
79 | 84 | ->shouldReturn($result);
|
80 | 85 |
|
81 | 86 | $this->setDirected(false);
|
82 | 87 |
|
83 |
| - $result = <<<EOF |
84 |
| -graph PHPTreeGraph { |
85 |
| -// The graph attributes. |
86 |
| - ratio = fill |
87 |
| - node [style="filled"] |
| 88 | + $result = implode( |
| 89 | + PHP_EOL, |
| 90 | + [ |
| 91 | + 'graph PHPTreeGraph {', |
| 92 | + '// The graph attributes.', |
| 93 | + ' ratio = fill', |
| 94 | + ' node [style="filled"]', |
| 95 | + '', |
| 96 | + '// The graph nodes.', |
| 97 | + " \"{$nodes['root']['hash']}\" [label=\"{$nodes['root']['value']}\"]", |
| 98 | + " \"{$nodes['child1']['hash']}\" [label=\"{$nodes['child1']['value']}\"]", |
| 99 | + " \"{$nodes['child4']['hash']}\" [label=\"{$nodes['child4']['value']}\"]", |
| 100 | + " \"{$nodes['child2']['hash']}\" [label=\"{$nodes['child2']['value']}\"]", |
| 101 | + " \"{$nodes['child3']['hash']}\" [label=\"{$nodes['child3']['value']}\"]", |
| 102 | + '', |
| 103 | + '// The graph edges.', |
| 104 | + " \"{$nodes['root']['hash']}\" -- \"{$nodes['child1']['hash']}\";", |
| 105 | + " \"{$nodes['child1']['hash']}\" -- \"{$nodes['child4']['hash']}\";", |
| 106 | + " \"{$nodes['root']['hash']}\" -- \"{$nodes['child2']['hash']}\";", |
| 107 | + " \"{$nodes['root']['hash']}\" -- \"{$nodes['child3']['hash']}\";", |
| 108 | + '}', |
| 109 | + ] |
| 110 | + ); |
88 | 111 |
|
89 |
| -// The graph nodes. |
90 |
| - "{$nodes['root']['hash']}" [label="{$nodes['root']['value']}"] |
91 |
| - "{$nodes['child1']['hash']}" [label="{$nodes['child1']['value']}"] |
92 |
| - "{$nodes['child4']['hash']}" [label="{$nodes['child4']['value']}"] |
93 |
| - "{$nodes['child2']['hash']}" [label="{$nodes['child2']['value']}"] |
94 |
| - "{$nodes['child3']['hash']}" [label="{$nodes['child3']['value']}"] |
95 |
| -
|
96 |
| -// The graph edges. |
97 |
| - "{$nodes['root']['hash']}" -- "{$nodes['child1']['hash']}"; |
98 |
| - "{$nodes['child1']['hash']}" -- "{$nodes['child4']['hash']}"; |
99 |
| - "{$nodes['root']['hash']}" -- "{$nodes['child2']['hash']}"; |
100 |
| - "{$nodes['root']['hash']}" -- "{$nodes['child3']['hash']}"; |
101 |
| -} |
102 |
| -EOF; |
103 | 112 | $this
|
104 | 113 | ->export($tree)
|
105 | 114 | ->shouldReturn($result);
|
|
0 commit comments