|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Grafizzi\Graph\Tests\IG15019Test: 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\Node; |
|
29
|
|
|
|
|
30
|
|
|
require 'vendor/autoload.php'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* A recreation of Image_GraphViz bug_15019.phpt |
|
34
|
|
|
* |
|
35
|
|
|
* Image_GraphViz version author: Philippe Jausions <[email protected]> |
|
36
|
|
|
* |
|
37
|
|
|
* Bug 15019: "addCluster using attributes twice" |
|
38
|
|
|
* |
|
39
|
|
|
* Note 1: IG test does not actually test using attributes twice. |
|
40
|
|
|
* Note 2: IG test expects an abnormal result: attribute "0" being set to "". |
|
41
|
|
|
* Since this is an incorrect behavior, Grafizzi does not reproduce it. |
|
42
|
|
|
*/ |
|
43
|
|
|
class IG15019Test extends BaseGraphTest { |
|
44
|
|
|
|
|
45
|
|
|
public $expected = <<<EOT |
|
46
|
|
|
strict digraph Bug { |
|
47
|
|
|
subgraph cluster_0 { |
|
48
|
|
|
fontcolor=black; |
|
49
|
|
|
style=filled; |
|
50
|
|
|
label=Cluster; |
|
51
|
|
|
|
|
52
|
|
|
"Node"; |
|
53
|
|
|
} /* /subgraph cluster_0 */ |
|
54
|
|
|
} /* /digraph Bug */ |
|
55
|
|
|
|
|
56
|
|
|
EOT; |
|
57
|
|
|
|
|
58
|
|
|
public function setUp() : void { |
|
59
|
|
|
parent::setUpExtended('Bug', array('strict' => true)); |
|
|
|
|
|
|
60
|
|
|
$g = $this->Graph; |
|
61
|
|
|
$dic = $this->dic; |
|
62
|
|
|
$g->setDirected(true); |
|
63
|
|
|
|
|
64
|
|
|
$g->addChild($cluster0 = new Cluster($dic, 0, array( |
|
65
|
|
|
new Attribute($dic, 'fontcolor', 'black'), |
|
66
|
|
|
new Attribute($dic, 'style', 'filled'), |
|
67
|
|
|
new Attribute($dic, 'label', 'Cluster'), |
|
68
|
|
|
))); |
|
69
|
|
|
$cluster0->addChild($node = new Node($dic, 'Node')); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Tests Graph->build() |
|
74
|
|
|
*/ |
|
75
|
|
|
public function testBuild() { |
|
76
|
|
|
$this->check($this->expected, "Image_GraphViz bug test 15019 passed."); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @depends testBuild |
|
81
|
|
|
*/ |
|
82
|
|
|
public function testBuild2() { |
|
83
|
|
|
// 0 is the id of the cluster in setUp(). |
|
84
|
|
|
$cluster0 = $this->Graph->getChildByName(0); |
|
85
|
|
|
$this->assertNotNull($cluster0, "Numbered cluster found in graph."); |
|
86
|
|
|
// Add the same attribute a second time. |
|
87
|
|
|
$cluster0->setAttribute(new Attribute($this->dic, 'style', 'filled')); |
|
88
|
|
|
|
|
89
|
|
|
$this->check($this->expected, "Image_GraphViz bug test 15019 redone passed."); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
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 theSoncalls the wrong method in the parent class.