Issues (3099)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Tests/unit/Helper/Menu/MenuItemTest.php (3 issues)

Upgrade to new PHP Analysis Engine

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()
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.

Loading history...
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()
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.

Loading history...
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()
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.

Loading history...
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);
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);
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);
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