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\GraphTest: 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 | |||
25 | namespace Grafizzi\Graph\Tests; |
||
26 | |||
27 | require 'vendor/autoload.php'; |
||
28 | |||
29 | use \Grafizzi\Graph\Attribute; |
||
30 | use \Grafizzi\Graph\Graph; |
||
31 | |||
32 | /** |
||
33 | * Graph test case. |
||
34 | */ |
||
35 | class GraphTest extends BaseGraphTest { |
||
36 | |||
37 | public function setUp() : void { |
||
38 | parent::setUpExtended(); |
||
0 ignored issues
–
show
|
|||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Tests Graph->build() |
||
43 | */ |
||
44 | public function testBuild() { |
||
45 | $graph = $this->Graph->build(); |
||
46 | $this->assertEquals(<<<EOT |
||
47 | digraph G { |
||
48 | } /* /digraph G */ |
||
49 | |||
50 | EOT |
||
51 | , $graph, 'Empty unnamed graph matches expected format.'); |
||
52 | } |
||
53 | |||
54 | // Normal attributes list. |
||
55 | public function testBuildAttributesNormal() { |
||
56 | $this->Graph->setAttributes(array( |
||
57 | new Attribute($this->dic, 'foo', 'bar'), |
||
58 | new Attribute($this->dic, 'baz', 'quux'), |
||
59 | )); |
||
60 | $expected = <<<EOT |
||
61 | digraph G { |
||
62 | foo=bar; |
||
63 | baz=quux; |
||
64 | } /* /digraph G */ |
||
65 | |||
66 | EOT; |
||
67 | $actual = $this->Graph->build(); |
||
68 | $this->assertEquals($expected, $actual); |
||
69 | } |
||
70 | |||
71 | // Attribute list with empty title in middle. |
||
72 | 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. ![]() |
|||
73 | $this->Graph->setAttributes(array( |
||
74 | new Attribute($this->dic, 'foo', 'bar'), |
||
75 | new Attribute($this->dic, 'title', ''), |
||
76 | new Attribute($this->dic, 'baz', 'quux'), |
||
77 | )); |
||
78 | $expected = <<<EOT |
||
79 | digraph G { |
||
80 | foo=bar; |
||
81 | baz=quux; |
||
82 | } /* /digraph G */ |
||
83 | |||
84 | EOT; |
||
85 | $actual = $this->Graph->build(); |
||
86 | $this->assertEquals($expected, $actual); |
||
87 | } |
||
88 | |||
89 | // Attribute list with empty title as single attribute. |
||
90 | public function testBuildAttributesOnlyEmpty() { |
||
91 | $this->Graph->setAttributes(array( |
||
92 | new Attribute($this->dic, 'title', ''), |
||
93 | )); |
||
94 | $expected = <<<EOT |
||
95 | digraph G { |
||
96 | } /* /digraph G */ |
||
97 | |||
98 | EOT; |
||
99 | $actual = $this->Graph->build(); |
||
100 | $this->assertEquals($expected, $actual); |
||
101 | } |
||
102 | |||
103 | // Attribute list with empty title as last attribute. |
||
104 | 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. ![]() |
|||
105 | $this->Graph->setAttributes(array( |
||
106 | new Attribute($this->dic, 'foo', 'bar'), |
||
107 | new Attribute($this->dic, 'baz', 'quux'), |
||
108 | new Attribute($this->dic, 'title', ''), |
||
109 | )); |
||
110 | $expected = <<<EOT |
||
111 | digraph G { |
||
112 | foo=bar; |
||
113 | baz=quux; |
||
114 | } /* /digraph G */ |
||
115 | |||
116 | EOT; |
||
117 | $actual = $this->Graph->build(); |
||
118 | $this->assertEquals($expected, $actual); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Tests Graph::getAllowedChildTypes() |
||
123 | */ |
||
124 | public function testGetAllowedChildTypes() { |
||
125 | $types = Graph::getAllowedChildTypes(); |
||
126 | $this->assertTrue(is_array($types) && count($types) == 5, |
||
127 | 'Five child types allowed for Graphs.'); |
||
128 | ksort($types); |
||
129 | $expectedTypes = array( |
||
130 | 'cluster', |
||
131 | 'edge', |
||
132 | 'multiedge', |
||
133 | 'node', |
||
134 | 'subgraph', |
||
135 | ); |
||
136 | $this->assertEquals($expectedTypes, $types); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * Tests Graph->getDirected() |
||
141 | */ |
||
142 | public function testGetDirected() { |
||
143 | $dir = $this->Graph->getDirected(); |
||
144 | $this->assertEquals(true, $dir, "Graph is directed by default."); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Tests Graph::getType() |
||
149 | */ |
||
150 | public function testGetType() { |
||
151 | $this->Graph->setDirected(false); |
||
152 | $type = $this->Graph->getType(); |
||
153 | $this->assertEquals('graph', $type, 'Graph type is "graph".'); |
||
154 | |||
155 | $this->Graph->setDirected(true); |
||
156 | $type = $this->Graph->getType(); |
||
157 | $this->assertEquals('digraph', $type, 'Graph type is "digraph".'); |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * Tests Graph->setDirected() |
||
162 | */ |
||
163 | public function testSetDirected() { |
||
164 | $this->Graph->setDirected(false); |
||
165 | $this->assertFalse($this->Graph->getDirected(), |
||
166 | "Setting directed to false changes the result of getDirected()."); |
||
167 | } |
||
168 | } |
||
169 |
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.