1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Grafizzi\Graph\Tests\IG16872Test: 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\Cluster; |
28
|
|
|
use Grafizzi\Graph\Edge; |
29
|
|
|
use Grafizzi\Graph\Node; |
30
|
|
|
|
31
|
|
|
require 'vendor/autoload.php'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* A recreation of Image_GraphViz bug_16872.phpt |
35
|
|
|
* |
36
|
|
|
* Image_GraphViz version author: Philippe Jausions <[email protected]> |
37
|
|
|
* |
38
|
|
|
* Bug 16872: "Cluster IDs start with 'cluster'" |
39
|
|
|
*/ |
40
|
|
|
class IG16872Test extends BaseGraphTest { |
41
|
|
|
|
42
|
|
|
public $expected = <<<EOT |
43
|
|
|
digraph sp_d_rcp_001 { |
44
|
|
|
rankdir=LR; |
45
|
|
|
ranksep=0.75; |
46
|
|
|
|
47
|
|
|
courbe_rcp [ shape=box ]; |
48
|
|
|
detail_rcp [ shape=box ]; |
49
|
|
|
subgraph cluster_pck_courbe_rcp { |
50
|
|
|
color=green; |
51
|
|
|
label=pck_courbe_rcp; |
52
|
|
|
|
53
|
|
|
sp_d_rcp_001 [ shape=component ]; |
54
|
|
|
} /* /subgraph cluster_pck_courbe_rcp */ |
55
|
|
|
sp_d_rcp_001 -> courbe_rcp [ color=blue, label=S, id=Scourbe_rcp ]; |
56
|
|
|
sp_d_rcp_001 -> courbe_rcp [ color=red, label=D, id=Dcourbe_rcp ]; |
57
|
|
|
sp_d_rcp_001 -> detail_rcp [ color=blue, label=S, id=Sdetail_rcp ]; |
58
|
|
|
sp_d_rcp_001 -> detail_rcp [ color=red, label=D, id=Ddetail_rcp ]; |
59
|
|
|
} /* /digraph sp_d_rcp_001 */ |
60
|
|
|
|
61
|
|
|
EOT; |
62
|
|
|
|
63
|
|
|
public function setUp() : void { |
64
|
|
|
parent::setUpExtended('sp_d_rcp_001'); |
|
|
|
|
65
|
|
|
$g = $this->Graph; |
66
|
|
|
$dic = $this->dic; |
67
|
|
|
$g->setDirected(true); |
68
|
|
|
$g->setAttributes(array( |
69
|
|
|
new Attribute($dic, 'rankdir', 'LR'), |
70
|
|
|
new Attribute($dic, 'ranksep', .75), |
71
|
|
|
)); |
72
|
|
|
|
73
|
|
|
// Grafizzi emits elements in insertion order, so if we want these nodes to |
74
|
|
|
// appear above the cluster, they must be created before it, unlike the way |
75
|
|
|
// the test is build in Image_GraphViz. |
76
|
|
|
$result = array( |
77
|
|
|
array('tab' => 'courbe_rcp', 'action' => 'S'), |
78
|
|
|
array('tab' => 'courbe_rcp', 'action' => 'D'), |
79
|
|
|
array('tab' => 'detail_rcp', 'action' => 'S'), |
80
|
|
|
array('tab' => 'detail_rcp', 'action' => 'D'), |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
$lst_tab = array(); |
84
|
|
|
$boxShape = new Attribute($dic, 'shape', 'box'); |
85
|
|
|
foreach ($result as $row) { |
86
|
|
|
$table = $row['tab']; |
87
|
|
|
if (array_key_exists($table, $lst_tab) == false){ |
|
|
|
|
88
|
|
|
$g->addChild($$table = new Node($dic, $table, array($boxShape))); |
89
|
|
|
$lst_tab[] = $table; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$g->addChild($pck_courbe_rcp = new Cluster($dic, 'pck_courbe_rcp', array( |
94
|
|
|
new Attribute($dic, 'color', 'green'), |
95
|
|
|
new Attribute($dic, 'label', 'pck_courbe_rcp'), |
96
|
|
|
))); |
97
|
|
|
$pck_courbe_rcp->addChild($sp_d_rcp_001 = new Node($dic, 'sp_d_rcp_001', array( |
98
|
|
|
new Attribute($dic, 'shape', 'component'), |
99
|
|
|
))); |
100
|
|
|
|
101
|
|
|
foreach ($result as $row) { |
102
|
|
|
$table = $row['tab']; |
103
|
|
|
$action = $row['action']; |
104
|
|
|
$color = ($action == 'D') ? 'red' : 'blue'; |
105
|
|
|
$this->dic['logger']->debug("Edge source " . $sp_d_rcp_001->getBuildName() .", dest ". $$table->getBuildName()); |
106
|
|
|
$g->addChild(new Edge($dic, $sp_d_rcp_001, $$table, array( |
107
|
|
|
new Attribute($dic, 'color', $color), |
108
|
|
|
new Attribute($dic, 'label', $action), |
109
|
|
|
new Attribute($dic, 'id', $action . $table), |
110
|
|
|
))); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Tests Graph->build() |
116
|
|
|
*/ |
117
|
|
|
public function testBuild() { |
118
|
|
|
$this->check($this->expected, "Image_GraphViz bug test 16872 passed."); |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|
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.