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/AdminList/AdminListTest.php (32 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\AdminListBundle\Tests\AdminList;
4
5
use Kunstmaan\AdminListBundle\AdminList\AdminList;
6
use Kunstmaan\AdminListBundle\AdminList\BulkAction\BulkActionInterface;
7
use Kunstmaan\AdminListBundle\AdminList\Configurator\AdminListConfiguratorInterface;
8
use Kunstmaan\AdminListBundle\AdminList\FilterBuilder;
9
use Kunstmaan\AdminListBundle\AdminList\ItemAction\ItemActionInterface;
10
use Kunstmaan\AdminListBundle\AdminList\ListAction\ListActionInterface;
11
use Pagerfanta\Pagerfanta;
12
use PHPUnit\Framework\TestCase;
13
use Symfony\Component\HttpFoundation\Request;
14
15
/**
16
 * Class AdminListTest
17
 */
18
class AdminListTest extends TestCase
19
{
20
    /** @var AdminList */
21
    protected $adminList;
22
23
    public function setUp(): void
24
    {
25
        /** @var AdminListConfiguratorInterface */
26
        $configurator = $this->createMock(AdminListConfiguratorInterface::class);
27
28
        $configurator->method('getFilterBuilder')->willReturn(new FilterBuilder());
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        $configurator->method('getFields')->willReturn(['a', 'b']);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        $configurator->method('getExportFields')->willReturn(['c', 'd']);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
        $configurator->method('getCount')->willReturn('666');
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
        $configurator->method('getItems')->willReturn(['item']);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
        $configurator->method('getSortFields')->willReturn(['e']);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
        $configurator->method('canEdit')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        $configurator->method('canAdd')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
        $configurator->method('canView')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        $configurator->method('canDelete')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        $configurator->method('canExport')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
        $configurator->method('getIndexUrl')->willReturn([]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
        $configurator->method('getEditUrlFor')->willReturn([]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
        $configurator->method('getDeleteUrlFor')->willReturn([]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
        $configurator->method('getAddUrlFor')->willReturn([]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
        $configurator->method('getExportUrl')->willReturn([]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        $configurator->method('getViewUrlFor')->willReturn([]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $configurator->method('getValue')->willReturn('test');
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
        $configurator->method('getStringValue')->willReturn('stringtest');
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
        $configurator->method('getOrderBy')->willReturn('name');
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
        $configurator->method('getOrderDirection')->willReturn('up');
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
        $configurator->method('getItemActions')->willReturn([$this->createMock(ItemActionInterface::class)]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
        $configurator->method('hasItemActions')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
        $configurator->method('getListActions')->willReturn([$this->createMock(ListActionInterface::class)]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
        $configurator->method('hasListActions')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
        $configurator->method('getBulkActions')->willReturn([$this->createMock(BulkActionInterface::class)]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
        $configurator->method('hasBulkActions')->willReturn(true);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
        $configurator->method('getPagerfanta')->willReturn($this->createMock(Pagerfanta::class));
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
57
        $this->adminList = new AdminList($configurator);
58
    }
59
60
    public function testConstructor()
61
    {
62
        $configurator = $this->createMock(AdminListConfiguratorInterface::class);
63
64
        $configurator->expects($this->once())->method('buildFilters');
65
        $configurator->expects($this->once())->method('buildFields');
66
        $configurator->expects($this->once())->method('buildItemActions');
67
        $configurator->expects($this->once())->method('buildListActions');
68
69
        new AdminList($configurator);
0 ignored issues
show
$configurator is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminLi...tConfiguratorInterface>.

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);
Loading history...
70
    }
71
72
    public function testGetConfigurator()
73
    {
74
        $this->assertInstanceOf(AdminListConfiguratorInterface::class, $this->adminList->getConfigurator());
75
    }
76
77
    public function testGetFilterBuilder()
78
    {
79
        $this->assertInstanceOf(FilterBuilder::class, $this->adminList->getFilterBuilder());
80
    }
81
82
    public function testGetColumns()
83
    {
84
        $this->assertContains('a', $this->adminList->getColumns());
85
    }
86
87
    public function testGetExportColumns()
88
    {
89
        $this->assertContains('c', $this->adminList->getExportColumns());
90
    }
91
92
    public function testGetCount()
93
    {
94
        $this->assertEquals(666, $this->adminList->getCount());
95
    }
96
97
    public function testGetItems()
98
    {
99
        $this->assertContains('item', $this->adminList->getItems());
100
    }
101
102
    public function testHasSort()
103
    {
104
        $this->assertTrue($this->adminList->hasSort());
105
        $this->assertTrue($this->adminList->hasSort('e'));
106
        $this->assertFalse($this->adminList->hasSort('x'));
107
    }
108
109
    public function testHasSortWithoutColumns()
110
    {
111
        $configurator = $this->createMock(AdminListConfiguratorInterface::class);
112
        $configurator->method('getSortFields')->willReturn([]);
0 ignored issues
show
The method method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
113
114
        $adminList = new AdminList($configurator);
0 ignored issues
show
$configurator is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminLi...tConfiguratorInterface>.

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);
Loading history...
115
116
        $this->assertFalse($adminList->hasSort());
117
    }
118
119
    public function testCanEdit()
120
    {
121
        $item = new \stdClass();
122
        $this->assertTrue($this->adminList->canEdit($item));
123
    }
124
125
    public function testCanAdd()
126
    {
127
        $this->assertTrue($this->adminList->canAdd());
128
    }
129
130
    public function testCanView()
131
    {
132
        $item = new \stdClass();
133
        $this->assertTrue($this->adminList->canView($item));
134
    }
135
136
    public function testCanDelete()
137
    {
138
        $item = new \stdClass();
139
        $this->assertTrue($this->adminList->canDelete($item));
140
    }
141
142
    public function testCanExport()
143
    {
144
        $this->assertTrue($this->adminList->canExport());
145
    }
146
147
    public function testGetIndexUrl()
148
    {
149
        $this->assertTrue(\is_array($this->adminList->getIndexUrl()));
150
    }
151
152
    public function testGetEditUrlFor()
153
    {
154
        $item = new \stdClass();
155
        $this->assertTrue(\is_array($this->adminList->getEditUrlFor($item)));
156
    }
157
158
    public function testGetDeleteUrlFor()
159
    {
160
        $item = new \stdClass();
161
        $this->assertTrue(\is_array($this->adminList->getDeleteUrlFor($item)));
162
    }
163
164
    public function testGetAddUrlFor()
165
    {
166
        $this->assertTrue(\is_array($this->adminList->getAddUrlFor([])));
167
    }
168
169
    public function testGetExportUrl()
170
    {
171
        $this->assertTrue(\is_array($this->adminList->getExportUrl()));
172
    }
173
174
    public function testGetViewUrl()
175
    {
176
        $item = new \stdClass();
177
        $this->assertTrue(\is_array($this->adminList->getViewUrlFor($item)));
178
    }
179
180
    public function testGetValue()
181
    {
182
        $object = new \stdClass();
183
        $this->assertEquals('test', $this->adminList->getValue($object, 'test'));
184
    }
185
186
    public function testGetStringValue()
187
    {
188
        $object = new \stdClass();
189
        $this->assertEquals('stringtest', $this->adminList->getStringValue($object, 'test'));
190
    }
191
192
    public function testGetOrderBy()
193
    {
194
        $this->assertEquals('name', $this->adminList->getOrderBy());
195
    }
196
197
    public function testGetOrderDirection()
198
    {
199
        $this->assertEquals('up', $this->adminList->getOrderDirection());
200
    }
201
202
    public function testGetItemActions()
203
    {
204
        $itemActions = $this->adminList->getItemActions();
205
        $this->assertTrue(\is_array($itemActions));
206
        $this->assertInstanceOf(ItemActionInterface::class, current($itemActions));
207
    }
208
209
    public function testHasItemActions()
210
    {
211
        $this->assertTrue($this->adminList->hasItemActions());
212
    }
213
214
    public function testHasListActions()
215
    {
216
        $this->assertTrue($this->adminList->hasListActions());
217
    }
218
219
    public function testGetListActions()
220
    {
221
        $listActions = $this->adminList->getListActions();
222
        $this->assertTrue(\is_array($listActions));
223
        $this->assertInstanceOf(ListActionInterface::class, current($listActions));
224
    }
225
226
    public function testGetBulkActions()
227
    {
228
        $bulkActions = $this->adminList->getBulkActions();
229
        $this->assertTrue(\is_array($bulkActions));
230
        $this->assertInstanceOf(BulkActionInterface::class, current($bulkActions));
231
    }
232
233
    public function testHasBulkActions()
234
    {
235
        $this->assertTrue($this->adminList->hasBulkActions());
236
    }
237
238
    public function testGetPagerfanta()
239
    {
240
        $this->assertInstanceOf(Pagerfanta::class, $this->adminList->getPagerfanta());
241
    }
242
243
    public function testBindRequest()
244
    {
245
        $configurator = $this->createMock(AdminListConfiguratorInterface::class);
246
247
        $configurator->expects($this->once())->method('bindRequest');
248
        $adminList = new AdminList($configurator);
0 ignored issues
show
$configurator is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminLi...tConfiguratorInterface>.

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);
Loading history...
249
250
        $adminList->bindRequest(new Request());
251
    }
252
}
253