1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Grafizzi\Graph\Tests\IG15943Test: 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
|
|
|
|
27
|
|
|
use Grafizzi\Graph\Attribute; |
28
|
|
|
use Grafizzi\Graph\Cluster; |
29
|
|
|
use Grafizzi\Graph\Edge; |
30
|
|
|
use Grafizzi\Graph\Node; |
31
|
|
|
|
32
|
|
|
require 'vendor/autoload.php'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* A recreation of Image_GraphViz test15943.phpt |
36
|
|
|
* |
37
|
|
|
* Image_GraphViz version author: Philippe Jausions <[email protected]> |
38
|
|
|
* |
39
|
|
|
* Test for bug #15943: "Nested subgraphs" |
40
|
|
|
*/ |
41
|
|
|
class IG15943Test extends BaseGraphTest { |
42
|
|
|
|
43
|
|
|
public function setUp() : void { |
44
|
|
|
// not strict by default. |
45
|
|
|
parent::setUpExtended('G', array('strict' => true)); |
|
|
|
|
46
|
|
|
$g = $this->Graph; |
47
|
|
|
$dic = $this->dic; |
48
|
|
|
$g->setDirected(true); |
49
|
|
|
|
50
|
|
|
$nullTitle = array(new Attribute($dic, 'title', null)); |
51
|
|
|
|
52
|
|
|
$g->addChild($node5 = new Node($dic, 'node5')); |
53
|
|
|
$g->addChild($clusterA = new Cluster($dic, 'A')); |
54
|
|
|
$clusterA->addChild($node0 = new Node($dic, 'node0', $nullTitle)); |
55
|
|
|
$clusterA->addChild($node1 = new Node($dic, 'node1', $nullTitle)); |
56
|
|
|
$clusterA->addChild($clusterB = new Cluster($dic, 'B', array( |
57
|
|
|
new Attribute($dic, 'label', 'Cluster B'), |
58
|
|
|
))); |
59
|
|
|
|
60
|
|
|
$clusterB->addChild($node2 = new Node($dic, 'node2', array( |
61
|
|
|
new Attribute($dic, 'color', 'blue'), |
62
|
|
|
))); |
63
|
|
|
$clusterB->addChild($node3 = new Node($dic, 'node3', $nullTitle)); |
64
|
|
|
|
65
|
|
|
$clusterA->addChild($clusterC = new Cluster($dic, 'C', $nullTitle)); |
66
|
|
|
$clusterB->addChild($clusterD = new Cluster($dic, 'D', $nullTitle)); |
67
|
|
|
|
68
|
|
|
$clusterC->addChild($node4 = new Node($dic, 'node4', $nullTitle)); |
69
|
|
|
$clusterD->addChild($node6 = new Node($dic, 'node6', $nullTitle)); |
70
|
|
|
|
71
|
|
|
$g->addChild(new Edge($dic, $node0, $node1)); |
72
|
|
|
$g->addChild(new Edge($dic, $node0, $node4)); |
73
|
|
|
$g->addChild(new Edge($dic, $node2, $node3)); |
74
|
|
|
$g->addChild(new Edge($dic, $node4, $node5)); |
75
|
|
|
$g->addChild(new Edge($dic, $node5, $node6)); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Tests Graph->build() |
80
|
|
|
*/ |
81
|
|
|
public function testBuild() { |
82
|
|
|
$expected = <<<'EOT' |
83
|
|
|
strict digraph G { |
84
|
|
|
node5; |
85
|
|
|
subgraph cluster_A { |
86
|
|
|
node0; |
87
|
|
|
node1; |
88
|
|
|
subgraph cluster_B { |
89
|
|
|
label="Cluster B"; |
90
|
|
|
|
91
|
|
|
node2 [ color=blue ]; |
92
|
|
|
node3; |
93
|
|
|
subgraph cluster_D { |
94
|
|
|
node6; |
95
|
|
|
} /* /subgraph cluster_D */ |
96
|
|
|
} /* /subgraph cluster_B */ |
97
|
|
|
subgraph cluster_C { |
98
|
|
|
node4; |
99
|
|
|
} /* /subgraph cluster_C */ |
100
|
|
|
} /* /subgraph cluster_A */ |
101
|
|
|
node0 -> node1; |
102
|
|
|
node0 -> node4; |
103
|
|
|
node2 -> node3; |
104
|
|
|
node4 -> node5; |
105
|
|
|
node5 -> node6; |
106
|
|
|
} /* /digraph G */ |
107
|
|
|
|
108
|
|
|
EOT; |
109
|
|
|
$this->check($expected, "Image_GraphViz test 15943 passed."); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
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.