This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @file |
||
5 | * Grafizzi\Graph\Tests\MultiEdgeTest: 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\MultiEdge; |
||
28 | use Grafizzi\Graph\Node; |
||
29 | |||
30 | require 'vendor/autoload.php'; |
||
31 | |||
32 | /** |
||
33 | * A test for Grafizzi "Multiedges". |
||
34 | * |
||
35 | * No equivalent in Image_GraphViz. |
||
36 | * |
||
37 | * @author Frédéric G. Marand <[email protected]> |
||
38 | * |
||
39 | * Graph definition taken from Neato documentation, fig. 5 p. 6 |
||
40 | * "Drawing graphs with NEATO" / Stephen C. North / April 26, 2004 |
||
41 | */ |
||
42 | class MultiEdgeTest extends BaseGraphTest { |
||
43 | |||
44 | /** |
||
45 | * |
||
46 | * @var MultiEdge |
||
47 | */ |
||
48 | private $MultiEdge; |
||
49 | |||
50 | /** |
||
51 | * Prepares the environment before running a test. |
||
52 | */ |
||
53 | protected function setUp() : void { |
||
54 | parent::setUpExtended(); |
||
0 ignored issues
–
show
|
|||
55 | |||
56 | $this->Graph->setDirected(false); |
||
57 | $nodes = array(); |
||
58 | for ($i = 0 ; $i < 4 ; $i++) { |
||
59 | $this->Graph->addChild($nodes[] = new Node($this->dic, "n$i", Node::implicit())); |
||
60 | } |
||
61 | |||
62 | // Test case is n0 -- n1 -- n2 -- n3 -- n0, so append n0 |
||
63 | $nodes[] = $nodes[0]; |
||
64 | $this->MultiEdge = new MultiEdge($this->dic, $nodes); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Cleans up the environment after running a test. |
||
69 | */ |
||
70 | protected function tearDown() : void { |
||
71 | $this->MultiEdge = null; |
||
72 | parent::tearDown(); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Tests MultiEdge->build() |
||
77 | */ |
||
78 | public function testBuild() { |
||
79 | // Test unbound multiedge. |
||
80 | $expected = <<<EOT |
||
81 | n0 -- n1 -- n2 -- n3 -- n0; |
||
82 | |||
83 | EOT; |
||
84 | $build = $this->MultiEdge->build(false); |
||
85 | $this->assertEquals($expected, $build, "Unbound undirected multiedge without attributes built correctly."); |
||
86 | |||
87 | // Test bound multiedge. |
||
88 | $this->Graph->setDirected(false); |
||
89 | $this->Graph->addChild($this->MultiEdge); |
||
90 | $expected = <<<EOT |
||
91 | n0 -- n1 -- n2 -- n3 -- n0; |
||
92 | |||
93 | EOT; |
||
94 | $build = $this->MultiEdge->build(); |
||
95 | $this->assertEquals($expected, $build, "Undirected multiedge bound to root graph without attributes built correctly."); |
||
96 | |||
97 | // Test full graph build. |
||
98 | $expected = <<<EOT |
||
99 | graph G { |
||
100 | n0 -- n1 -- n2 -- n3 -- n0; |
||
101 | } /* /graph G */ |
||
102 | |||
103 | EOT; |
||
104 | $build = $this->Graph->build(); |
||
105 | $this->assertEquals($expected, $build, "Graph with undirected multiedge without attributes built correctly."); |
||
106 | |||
107 | // Test full graph with attributes. |
||
108 | $this->MultiEdge->setAttributes(array( |
||
109 | new Attribute($this->dic, 'label', 'Multiedge label'), |
||
110 | )); |
||
111 | $expected = <<<EOT |
||
112 | graph G { |
||
113 | n0 -- n1 -- n2 -- n3 -- n0 [ label="Multiedge label" ]; |
||
114 | } /* /graph G */ |
||
115 | |||
116 | EOT; |
||
117 | $build = $this->Graph->build(); |
||
118 | $this->assertEquals($expected, $build, "Graph with undirected multiedge with attributes built correctly."); |
||
119 | } |
||
120 | |||
121 | // Normal attributes list on unbound multiedge. |
||
122 | View Code Duplication | public function testBuildAttributesNormal() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
123 | $this->MultiEdge->setAttributes(array( |
||
124 | new Attribute($this->dic, 'foo', 'bar'), |
||
125 | new Attribute($this->dic, 'baz', 'quux'), |
||
126 | )); |
||
127 | $expected = <<<EOT |
||
128 | n0 -- n1 -- n2 -- n3 -- n0 [ foo=bar, baz=quux ]; |
||
129 | |||
130 | EOT; |
||
131 | $actual = $this->MultiEdge->build(false); |
||
132 | $this->assertEquals($expected, $actual); |
||
133 | } |
||
134 | |||
135 | // Attribute list with empty title in middle on unbound multiedge. |
||
136 | View Code Duplication | public function testBuildAttributesEmptyMiddle() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
137 | $this->MultiEdge->setAttributes(array( |
||
138 | new Attribute($this->dic, 'foo', 'bar'), |
||
139 | new Attribute($this->dic, 'title', ''), |
||
140 | new Attribute($this->dic, 'baz', 'quux'), |
||
141 | )); |
||
142 | $expected = <<<EOT |
||
143 | n0 -- n1 -- n2 -- n3 -- n0 [ foo=bar, baz=quux ]; |
||
144 | |||
145 | EOT; |
||
146 | $actual = $this->MultiEdge->build(false); |
||
147 | $this->assertEquals($expected, $actual); |
||
148 | } |
||
149 | |||
150 | // Attribute list with empty title as single attribute on unbound multiedge. |
||
151 | public function testBuildAttributesOnlyEmpty() { |
||
152 | $this->MultiEdge->setAttributes(array( |
||
153 | new Attribute($this->dic, 'title', ''), |
||
154 | )); |
||
155 | $expected = <<<EOT |
||
156 | n0 -- n1 -- n2 -- n3 -- n0; |
||
157 | |||
158 | EOT; |
||
159 | $actual = $this->MultiEdge->build(false); |
||
160 | $this->assertEquals($expected, $actual); |
||
161 | } |
||
162 | |||
163 | // Attribute list with empty title as last attribute on unbound multiedge. |
||
164 | View Code Duplication | public function testBuildAttributesEmptyLast() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
165 | $this->MultiEdge->setAttributes(array( |
||
166 | new Attribute($this->dic, 'foo', 'bar'), |
||
167 | new Attribute($this->dic, 'baz', 'quux'), |
||
168 | new Attribute($this->dic, 'title', ''), |
||
169 | )); |
||
170 | $expected = <<<EOT |
||
171 | n0 -- n1 -- n2 -- n3 -- n0 [ foo=bar, baz=quux ]; |
||
172 | |||
173 | EOT; |
||
174 | $actual = $this->MultiEdge->build(false); |
||
175 | $this->assertEquals($expected, $actual); |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * Tests MultiEdge::getAllowedChildTypes() |
||
180 | */ |
||
181 | public function testGetAllowedChildTypes() { |
||
182 | $this->assertEmpty(MultiEdge::getAllowedChildTypes(), 'MultiEdge does not support children.'); |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * Tests MultiEdge->getType() |
||
187 | */ |
||
188 | public function testGetType() { |
||
189 | $this->assertEquals('multiedge', $this->MultiEdge->getType()); |
||
190 | } |
||
191 | } |
||
192 |
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.