1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Grafizzi\Graph\Tests\IG18676Test: 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_18676.phpt |
34
|
|
|
* |
35
|
|
|
* Image_GraphViz version author: Frédéric G. Marand <[email protected]> |
36
|
|
|
* |
37
|
|
|
* Request 18676: "Cluster doesn't show if there's no nodes inside." |
38
|
|
|
* |
39
|
|
|
* @link http://pear.php.net/bugs/bug.php?id=18676 |
40
|
|
|
*/ |
41
|
|
View Code Duplication |
class IG18676Test extends BaseGraphTest { |
|
|
|
|
42
|
|
|
|
43
|
|
|
public $expected = <<<EOT |
44
|
|
|
strict digraph G { |
45
|
|
|
subgraph cluster_c1_id { |
46
|
|
|
label=c1_title; |
47
|
|
|
} /* /subgraph cluster_c1_id */ |
48
|
|
|
} /* /digraph G */ |
49
|
|
|
|
50
|
|
|
EOT; |
51
|
|
|
|
52
|
|
|
public function setUp() : void { |
53
|
|
|
parent::setUpExtended('G', array('strict' => true)); |
|
|
|
|
54
|
|
|
$g = $this->Graph; |
55
|
|
|
$dic = $this->dic; |
56
|
|
|
$g->setDirected(true); |
57
|
|
|
|
58
|
|
|
$g->addChild($cluster = new Cluster($dic, 'c1_id', array( |
59
|
|
|
new Attribute($dic, 'label', 'c1_title'), |
60
|
|
|
))); |
61
|
|
|
$cluster->addChild(new Node($dic, 'n', array('implicit' => true))); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Tests Graph->build() |
66
|
|
|
*/ |
67
|
|
|
public function testBuild() { |
68
|
|
|
$this->check($this->expected, "Image_GraphViz bug test 18676 passed."); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.