|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Grafizzi\Graph\Tests\IG14Test: 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 test14.phpt |
|
34
|
|
|
* |
|
35
|
|
|
* Image_GraphViz version author: Philippe Jausions <[email protected]> |
|
36
|
|
|
* |
|
37
|
|
|
* Test 14: "Drawing of records (revisited)" |
|
38
|
|
|
* |
|
39
|
|
|
* Graph definition taken from GraphViz documentation |
|
40
|
|
|
*/ |
|
41
|
|
|
class IG14Test extends BaseGraphTest { |
|
42
|
|
|
|
|
43
|
|
|
public function setUp() : void { |
|
44
|
|
|
// not strict by default. |
|
45
|
|
|
parent::setUpExtended('structs'); |
|
|
|
|
|
|
46
|
|
|
$g = $this->Graph; |
|
47
|
|
|
$dic = $this->dic; |
|
48
|
|
|
$g->setDirected(true); |
|
49
|
|
|
|
|
50
|
|
|
$recordShape = new Attribute($dic, 'shape', 'record'); |
|
51
|
|
|
$g->addChild($struct1 = new Node($dic, 'struct1', array( |
|
52
|
|
|
$recordShape, |
|
53
|
|
|
new Attribute($dic, 'label', '<f0> left|<f1> middle|<f2> right'), |
|
54
|
|
|
))); |
|
55
|
|
|
$g->addChild($struct2 = new Node($dic, 'struct2', array( |
|
56
|
|
|
$recordShape, |
|
57
|
|
|
new Attribute($dic, 'label', '<f0> one|<f1> two'), |
|
58
|
|
|
))); |
|
59
|
|
|
$g->addChild($struct3 = new Node($dic, 'struct3', array( |
|
60
|
|
|
$recordShape, |
|
61
|
|
|
new Attribute($dic, 'label', "hello\nworld | { b |{c|<here> d|e}| f}| g | h"), |
|
62
|
|
|
))); |
|
63
|
|
|
|
|
64
|
|
|
$g->addChild(new Edge($dic, $struct1, $struct2, array(), 'f1', 'f0')); |
|
65
|
|
|
$g->addchild(new Edge($dic, $struct1, $struct3, array(), 'f1', 'here')); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Tests Graph->build() |
|
70
|
|
|
*/ |
|
71
|
|
|
public function testBuild() { |
|
72
|
|
|
$expected = <<<'EOT' |
|
73
|
|
|
digraph structs { |
|
74
|
|
|
struct1 [ shape=record, label="<f0> left|<f1> middle|<f2> right" ]; |
|
75
|
|
|
struct2 [ shape=record, label="<f0> one|<f1> two" ]; |
|
76
|
|
|
struct3 [ shape=record, label="hello\nworld | { b |{c|<here> d|e}| f}| g | h" ]; |
|
77
|
|
|
struct1:f1 -> struct2:f0; |
|
78
|
|
|
struct1:f1 -> struct3:here; |
|
79
|
|
|
} /* /digraph structs */ |
|
80
|
|
|
|
|
81
|
|
|
EOT; |
|
82
|
|
|
$this->check($expected, "Image_GraphViz test 14 passed."); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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.