|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Grafizzi\Graph\Tests\IG06Test: 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\Edge; |
|
29
|
|
|
use Grafizzi\Graph\Graph; |
|
30
|
|
|
use Grafizzi\Graph\Node; |
|
31
|
|
|
use Grafizzi\Graph\Subgraph; |
|
32
|
|
|
|
|
33
|
|
|
require 'vendor/autoload.php'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* A recreation of Image_GraphViz test6.phpt |
|
37
|
|
|
* |
|
38
|
|
|
* Image_GraphViz version author: Philippe Jausions <[email protected]> |
|
39
|
|
|
* |
|
40
|
|
|
* Test 6: "Unit test for nodes, subgraphs and clusters using keyword as name" |
|
41
|
|
|
* |
|
42
|
|
|
* Note: called Test 5 internally in the Image_GraphViz test6.phpt file. |
|
43
|
|
|
*/ |
|
44
|
|
|
class IG06Test extends BaseGraphTest { |
|
45
|
|
|
|
|
46
|
|
|
public function setUp() : void { |
|
47
|
|
|
parent::setUpExtended('G', Graph::strict()); |
|
|
|
|
|
|
48
|
|
|
$graph = &$this->Graph; |
|
49
|
|
|
$dic = $this->dic; |
|
50
|
|
|
$graph->setName('strict'); |
|
51
|
|
|
$graph->addChild($graphNode = new Node($dic, 'graph')); |
|
52
|
|
|
|
|
53
|
|
|
$graph->addChild($subgraph = new Subgraph($dic, 'subgraph')); |
|
54
|
|
|
$subgraph->setAttribute(new Attribute($dic, 'title', '')); |
|
55
|
|
|
|
|
56
|
|
|
$graph->addChild($digraph = new Subgraph($dic, 'digraph')); |
|
57
|
|
|
$digraph->setName('digraph'); |
|
58
|
|
|
$digraph->setAttribute(new Attribute($dic, 'title', '')); |
|
59
|
|
|
|
|
60
|
|
|
// Note: API difference from Image_GraphViz: the "group" is now defined by |
|
61
|
|
|
// the element to which a child is added, not by a separate "group" |
|
62
|
|
|
// parameter on constructor. |
|
63
|
|
|
$subgraph->addChild($node = new Node($dic, 'node')); |
|
64
|
|
|
$digraph->addChild($edge = new Node($dic, 'edge')); |
|
65
|
|
|
|
|
66
|
|
|
$graph->addChild(new Edge($dic, $node, $edge)); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Tests Graph->build() |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testBuild() { |
|
73
|
|
|
$expected = <<<EOT |
|
74
|
|
|
strict digraph "strict" { |
|
75
|
|
|
"graph"; |
|
76
|
|
|
subgraph "subgraph" { |
|
77
|
|
|
"node"; |
|
78
|
|
|
} /* /subgraph "subgraph" */ |
|
79
|
|
|
subgraph "digraph" { |
|
80
|
|
|
"edge"; |
|
81
|
|
|
} /* /subgraph "digraph" */ |
|
82
|
|
|
"node" -> "edge"; |
|
83
|
|
|
} /* /digraph "strict" */ |
|
84
|
|
|
|
|
85
|
|
|
EOT; |
|
86
|
|
|
$this->check($expected, "Image_GraphViz test 6 passed."); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
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.