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 | namespace Kunstmaan\AdminBundle\Tests\Helper\Menu; |
||
4 | |||
5 | use Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder; |
||
6 | use Kunstmaan\AdminBundle\Helper\Menu\MenuItem; |
||
7 | use Kunstmaan\AdminBundle\Helper\Menu\TopMenuItem; |
||
8 | use PHPUnit\Framework\TestCase; |
||
9 | |||
10 | class MenuItemTest extends TestCase |
||
11 | { |
||
12 | /** |
||
13 | * @var MenuItem |
||
14 | */ |
||
15 | protected $object; |
||
16 | |||
17 | /** |
||
18 | * Sets up the fixture, for example, opens a network connection. |
||
19 | * This method is called before a test is executed. |
||
20 | */ |
||
21 | protected function setUp(): void |
||
22 | { |
||
23 | /* @var $menuBuilder MenuBuilder */ |
||
24 | $menuBuilder = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder') |
||
25 | ->disableOriginalConstructor() |
||
26 | ->getMock(); |
||
27 | |||
28 | $this->object = new MenuItem($menuBuilder); |
||
29 | } |
||
30 | |||
31 | public function testGetMenu() |
||
32 | { |
||
33 | /* @var $menuBuilder MenuBuilder */ |
||
34 | $menuBuilder = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder') |
||
35 | ->disableOriginalConstructor() |
||
36 | ->getMock(); |
||
37 | |||
38 | $object = new MenuItem($menuBuilder); |
||
39 | $this->assertEquals($menuBuilder, $object->getMenu()); |
||
40 | } |
||
41 | |||
42 | public function testGetSetLabel() |
||
43 | { |
||
44 | $this->object->setLabel('label'); |
||
45 | $this->assertEquals('label', $this->object->getLabel()); |
||
46 | } |
||
47 | |||
48 | public function testGetSetUniqueId() |
||
49 | { |
||
50 | $this->object->setUniqueId('uniqueId'); |
||
51 | $this->assertEquals('uniqueId', $this->object->getUniqueId()); |
||
52 | } |
||
53 | |||
54 | public function testGetSetRole() |
||
55 | { |
||
56 | $this->object->setRole('ROLE_CUSTOM'); |
||
57 | $this->assertEquals('ROLE_CUSTOM', $this->object->getRole()); |
||
58 | } |
||
59 | |||
60 | public function testGetSetChildren() |
||
61 | { |
||
62 | $this->object->setChildren(['test' => 'ok']); |
||
63 | $this->assertNotEmpty($this->object->getChildren()); |
||
64 | $this->assertNotNull($this->object->getChildren()['test']); |
||
65 | } |
||
66 | |||
67 | View Code Duplication | public function testGetSetOffline() |
|
68 | { |
||
69 | $this->object->setOffline(true); |
||
70 | $this->assertTrue($this->object->getOffline()); |
||
71 | $this->object->setOffline(false); |
||
72 | $this->assertFalse($this->object->getOffline()); |
||
73 | $this->object->setOffline(true); |
||
74 | $this->assertTrue($this->object->getOffline()); |
||
75 | } |
||
76 | |||
77 | View Code Duplication | public function testGetSetHiddenFromNav() |
|
78 | { |
||
79 | $this->object->setHiddenFromNav(true); |
||
80 | $this->assertTrue($this->object->isHiddenFromNav()); |
||
81 | $this->object->setHiddenFromNav(false); |
||
82 | $this->assertFalse($this->object->isHiddenFromNav()); |
||
83 | $this->object->setHiddenFromNav(true); |
||
84 | $this->assertTrue($this->object->isHiddenFromNav()); |
||
85 | } |
||
86 | |||
87 | View Code Duplication | public function testGetSetFolder() |
|
88 | { |
||
89 | $this->object->setFolder(true); |
||
90 | $this->assertTrue($this->object->getFolder()); |
||
91 | $this->object->setFolder(false); |
||
92 | $this->assertFalse($this->object->getFolder()); |
||
93 | $this->object->setFolder(true); |
||
94 | $this->assertTrue($this->object->getFolder()); |
||
95 | } |
||
96 | |||
97 | public function testGetSetParent() |
||
98 | { |
||
99 | /* @var $menuBuilder MenuBuilder */ |
||
100 | $menuBuilder = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder') |
||
101 | ->disableOriginalConstructor() |
||
102 | ->getMock(); |
||
103 | $parent = new MenuItem($menuBuilder); |
||
104 | $this->object->setParent($parent); |
||
105 | $this->assertEquals($parent, $this->object->getParent()); |
||
106 | } |
||
107 | |||
108 | public function testGetSetRoute() |
||
109 | { |
||
110 | $params = ['id' => 5]; |
||
111 | $this->object->setRoute('ARoute', $params); |
||
112 | |||
113 | $this->assertEquals('ARoute', $this->object->getRoute()); |
||
114 | $this->assertEquals($params, $this->object->getRouteParams()); |
||
115 | } |
||
116 | |||
117 | public function testGetSetRouteParams() |
||
118 | { |
||
119 | $params = ['id' => 1]; |
||
120 | $this->object->setRouteParams($params); |
||
121 | $this->assertEquals($params, $this->object->getRouteParams()); |
||
122 | } |
||
123 | |||
124 | View Code Duplication | public function testGetChildren() |
|
125 | { |
||
126 | $child1 = new MenuItem($this->object->getMenu()); |
||
127 | $child1->setAppearInNavigation(true); |
||
128 | $child2 = new MenuItem($this->object->getMenu()); |
||
129 | $child2->setAppearInNavigation(true); |
||
130 | $children = [$child1, $child2]; |
||
131 | |||
132 | $menuBuilder = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder') |
||
133 | ->disableOriginalConstructor() |
||
134 | ->getMock(); |
||
135 | $menuBuilder->expects($this->once()) |
||
136 | ->method('getChildren') |
||
137 | ->will($this->returnValue($children)); |
||
138 | |||
139 | /* @var $menuBuilder MenuBuilder */ |
||
140 | $parent = new MenuItem($menuBuilder); |
||
141 | $result = $parent->getChildren(); |
||
142 | $this->assertCount(2, $result); |
||
0 ignored issues
–
show
|
|||
143 | $this->assertEquals($children, $result); |
||
144 | } |
||
145 | |||
146 | View Code Duplication | public function testGetNavigationChildren() |
|
147 | { |
||
148 | $child1 = new MenuItem($this->object->getMenu()); |
||
149 | $child1->setAppearInNavigation(true); |
||
150 | $child2 = new MenuItem($this->object->getMenu()); |
||
151 | $child2->setAppearInNavigation(false); |
||
152 | $children = [$child1, $child2]; |
||
153 | |||
154 | $menuBuilder = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder') |
||
155 | ->disableOriginalConstructor() |
||
156 | ->getMock(); |
||
157 | $menuBuilder->expects($this->once()) |
||
158 | ->method('getChildren') |
||
159 | ->will($this->returnValue($children)); |
||
160 | |||
161 | /* @var $menuBuilder MenuBuilder */ |
||
162 | $parent = new MenuItem($menuBuilder); |
||
163 | $result = $parent->getNavigationChildren(); |
||
164 | $this->assertCount(1, $result); |
||
0 ignored issues
–
show
$result is of type array<integer,object<Kun...\Helper\Menu\MenuItem>> , but the function expects a object<Countable>|object...nit\Framework\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
165 | $this->assertEquals([$child1], $result); |
||
166 | } |
||
167 | |||
168 | public function testGetTopChildren() |
||
169 | { |
||
170 | $child1 = new MenuItem($this->object->getMenu()); |
||
171 | $child2 = new TopMenuItem($this->object->getMenu()); |
||
172 | $children = [$child1, $child2]; |
||
173 | |||
174 | $menuBuilder = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder') |
||
175 | ->disableOriginalConstructor() |
||
176 | ->getMock(); |
||
177 | $menuBuilder->expects($this->once()) |
||
178 | ->method('getChildren') |
||
179 | ->will($this->returnValue($children)); |
||
180 | |||
181 | /* @var $menuBuilder MenuBuilder */ |
||
182 | $parent = new MenuItem($menuBuilder); |
||
183 | $result = $parent->getTopChildren(); |
||
184 | $this->assertCount(1, $result); |
||
0 ignored issues
–
show
$result is of type array<integer,object<Kun...lper\Menu\TopMenuItem>> , but the function expects a object<Countable>|object...nit\Framework\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
185 | $this->assertEquals([$child2], $result); |
||
186 | } |
||
187 | |||
188 | public function testAddGetAttributes() |
||
189 | { |
||
190 | $attributes = ['attribute1' => 1, 'attribute2' => 2]; |
||
191 | $this->object->addAttributes($attributes); |
||
192 | $this->assertEquals($attributes, $this->object->getAttributes()); |
||
193 | } |
||
194 | |||
195 | public function testGetSetActive() |
||
196 | { |
||
197 | $this->object->setActive(true); |
||
198 | $this->assertTrue($this->object->getActive()); |
||
199 | } |
||
200 | |||
201 | public function testGetSetAppearInNavigation() |
||
202 | { |
||
203 | $this->object->setAppearInNavigation(true); |
||
204 | $this->assertTrue($this->object->getAppearInNavigation()); |
||
205 | } |
||
206 | |||
207 | public function testGetSetWeight() |
||
208 | { |
||
209 | $this->object->setWeight(10); |
||
210 | $this->assertEquals(10, $this->object->getWeight()); |
||
211 | } |
||
212 | } |
||
213 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: