1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Grafizzi\Graph\Tests\IG16Test: a component of the Grafizzi library. |
6
|
|
|
* |
7
|
|
|
* (c) 2012 Frédéric G. MARAND <[email protected]> |
8
|
|
|
* |
9
|
|
|
* Grafizzi is free software: you can redistribute it and/or modify it under the |
10
|
|
|
* terms of the GNU Lesser General Public License as published by the Free |
11
|
|
|
* Software Foundation, either version 3 of the License, or (at your option) any |
12
|
|
|
* later version. |
13
|
|
|
* |
14
|
|
|
* Grafizzi is distributed in the hope that it will be useful, but WITHOUT ANY |
15
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
16
|
|
|
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
17
|
|
|
* details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
20
|
|
|
* along with Grafizzi, in the COPYING.LESSER.txt file. If not, see |
21
|
|
|
* <http://www.gnu.org/licenses/> |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace Grafizzi\Graph\Tests; |
25
|
|
|
|
26
|
|
|
use Grafizzi\Graph\Attribute; |
27
|
|
|
use Grafizzi\Graph\Edge; |
28
|
|
|
use Grafizzi\Graph\Node; |
29
|
|
|
|
30
|
|
|
require 'vendor/autoload.php'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* A recreation of Image_GraphViz test16.phpt |
34
|
|
|
* |
35
|
|
|
* Image_GraphViz version author: Philippe Jausions <[email protected]> |
36
|
|
|
* |
37
|
|
|
* Test 16: "Drawing of hash table" |
38
|
|
|
* |
39
|
|
|
* "Graph definition taken from GraphViz documentation" |
40
|
|
|
*/ |
41
|
|
|
class IG16Test extends BaseGraphTest { |
42
|
|
|
|
43
|
|
|
public function setUp() : void { |
44
|
|
|
// not strict by default. |
45
|
|
|
parent::setUpExtended(); |
|
|
|
|
46
|
|
|
$g = $this->Graph; |
47
|
|
|
$dic = $this->dic; |
48
|
|
|
$g->setDirected(true); |
49
|
|
|
$g->setAttributes(array( |
50
|
|
|
new Attribute($dic, 'nodesep', 0.05), |
51
|
|
|
new Attribute($dic, 'rankdir', 'LR'), |
52
|
|
|
)); |
53
|
|
|
|
54
|
|
|
$recordShape = new Attribute($dic, 'shape', 'record'); |
55
|
|
|
|
56
|
|
|
$g->addChild($node0 = new Node($dic, 'node0', array( |
57
|
|
|
$recordShape, |
58
|
|
|
new Attribute($dic, 'label', '<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> | '), |
59
|
|
|
new Attribute($dic, 'height', 2.5), |
60
|
|
|
))); |
61
|
|
|
$g->addChild($node1 = new Node($dic, 'node1', array( |
62
|
|
|
$recordShape, |
63
|
|
|
new Attribute($dic, 'label', '{<n> n14 | 719 |<p> }'), |
64
|
|
|
))); |
65
|
|
|
$g->addChild($node2 = new Node($dic, 'node2', array( |
66
|
|
|
$recordShape, |
67
|
|
|
new Attribute($dic, 'label', '{<n> a1 | 805 |<p> }'), |
68
|
|
|
))); |
69
|
|
|
$g->addChild($node3 = new Node($dic, 'node3', array( |
70
|
|
|
$recordShape, |
71
|
|
|
new Attribute($dic, 'label', '{<n> i9 | 718 |<p> }'), |
72
|
|
|
))); |
73
|
|
|
$g->addChild($node4 = new Node($dic, 'node4', array( |
74
|
|
|
$recordShape, |
75
|
|
|
new Attribute($dic, 'label', '{<n> e5 | 989 |<p> }'), |
76
|
|
|
))); |
77
|
|
|
$g->addChild($node5 = new Node($dic, 'node5', array( |
78
|
|
|
$recordShape, |
79
|
|
|
new Attribute($dic, 'label', '{<n> t20 | 959 |<p> }'), |
80
|
|
|
))); |
81
|
|
|
$g->addChild($node6 = new Node($dic, 'node6', array( |
82
|
|
|
$recordShape, |
83
|
|
|
new Attribute($dic, 'label', '{<n> o15 | 794 |<p> }'), |
84
|
|
|
))); |
85
|
|
|
$g->addChild($node7 = new Node($dic, 'node7', array( |
86
|
|
|
$recordShape, |
87
|
|
|
new Attribute($dic, 'label', '{<n> s19 | 659 |<p> }'), |
88
|
|
|
))); |
89
|
|
|
|
90
|
|
|
$nullTitle = array( |
91
|
|
|
new Attribute($dic, 'title', null), |
92
|
|
|
); |
93
|
|
|
$g->addChild(new Edge($dic, $node0, $node1, $nullTitle, 'f0', 'n')); |
94
|
|
|
$g->addChild(new Edge($dic, $node0, $node2, $nullTitle, 'f1', 'n')); |
95
|
|
|
$g->addChild(new Edge($dic, $node0, $node3, $nullTitle, 'f2', 'n')); |
96
|
|
|
$g->addChild(new Edge($dic, $node0, $node4, $nullTitle, 'f5', 'n')); |
97
|
|
|
$g->addChild(new Edge($dic, $node0, $node5, $nullTitle, 'f6', 'n')); |
98
|
|
|
$g->addChild(new Edge($dic, $node2, $node6, $nullTitle, 'p', 'n')); |
99
|
|
|
$g->addChild(new Edge($dic, $node4, $node7, $nullTitle, 'p', 'n')); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Tests Graph->build() |
104
|
|
|
*/ |
105
|
|
|
public function testBuild() { |
106
|
|
|
$expected = <<<'EOT' |
107
|
|
|
digraph G { |
108
|
|
|
nodesep=0.05; |
109
|
|
|
rankdir=LR; |
110
|
|
|
|
111
|
|
|
node0 [ shape=record, label="<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> | ", height=2.5 ]; |
112
|
|
|
node1 [ shape=record, label="{<n> n14 | 719 |<p> }" ]; |
113
|
|
|
node2 [ shape=record, label="{<n> a1 | 805 |<p> }" ]; |
114
|
|
|
node3 [ shape=record, label="{<n> i9 | 718 |<p> }" ]; |
115
|
|
|
node4 [ shape=record, label="{<n> e5 | 989 |<p> }" ]; |
116
|
|
|
node5 [ shape=record, label="{<n> t20 | 959 |<p> }" ]; |
117
|
|
|
node6 [ shape=record, label="{<n> o15 | 794 |<p> }" ]; |
118
|
|
|
node7 [ shape=record, label="{<n> s19 | 659 |<p> }" ]; |
119
|
|
|
node0:f0 -> node1:n; |
120
|
|
|
node0:f1 -> node2:n; |
121
|
|
|
node0:f2 -> node3:n; |
122
|
|
|
node0:f5 -> node4:n; |
123
|
|
|
node0:f6 -> node5:n; |
124
|
|
|
node2:p -> node6:n; |
125
|
|
|
node4:p -> node7:n; |
126
|
|
|
} /* /digraph G */ |
127
|
|
|
|
128
|
|
|
EOT; |
129
|
|
|
$this->check($expected, "Image_GraphViz test 16 passed."); |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.