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 | /** @noinspection PhpUnitUndefinedDataProviderInspection */ |
||
3 | namespace Test\Vehsamrak\ListCollection; |
||
4 | |||
5 | use PHPUnit\Framework\TestCase; |
||
6 | use Vehsamrak\ListCollection\AbstractTypedList; |
||
7 | use Vehsamrak\ListCollection\Exceptions\InvalidTypeException; |
||
8 | |||
9 | abstract class AbstractListTest extends TestCase |
||
10 | { |
||
11 | /** |
||
12 | * @test |
||
13 | * @dataProvider getValidParameters |
||
14 | */ |
||
15 | public function construct_validConstructorParameters_newListCreatedWithNoExceptions(array $parameters): void |
||
16 | { |
||
17 | $integerList = null; |
||
18 | $exception = null; |
||
19 | |||
20 | try { |
||
21 | $integerList = $this->createList($parameters); |
||
22 | } catch (\Exception $exception) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
![]() |
|||
23 | } |
||
24 | |||
25 | $this->assertInstanceOf($this->getListClassName(), $integerList); |
||
26 | $this->assertNull($exception); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @test |
||
31 | * @dataProvider getInvalidParameters |
||
32 | */ |
||
33 | View Code Duplication | public function construct_invalidConstructorParameters_invalidTypeExceptionThrowed(array $parameters): void |
|
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. ![]() |
|||
34 | { |
||
35 | $integerList = null; |
||
36 | $exception = null; |
||
37 | |||
38 | try { |
||
39 | $integerList = $this->createList($parameters); |
||
40 | } catch (\Exception $exception) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
41 | } |
||
42 | |||
43 | $this->assertNull($integerList); |
||
44 | $this->assertInstanceOf(InvalidTypeException::class, $exception); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @test |
||
49 | * @dataProvider getValidParameters |
||
50 | */ |
||
51 | public function add_validParameters_noExceptions(array $parameters): void |
||
52 | { |
||
53 | $integerList = $this->createList(); |
||
54 | $exception = null; |
||
55 | |||
56 | try { |
||
57 | foreach ($parameters as $parameter) { |
||
58 | $integerList->add($parameter); |
||
59 | } |
||
60 | } catch (\Exception $exception) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
61 | } |
||
62 | |||
63 | $this->assertNull($exception); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @test |
||
68 | * @dataProvider getInvalidParameters |
||
69 | */ |
||
70 | View Code Duplication | public function add_invalidParameters_noExceptions(array $parameters): void |
|
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. ![]() |
|||
71 | { |
||
72 | $integerList = $this->createList(); |
||
73 | $exception = null; |
||
74 | |||
75 | try { |
||
76 | foreach ($parameters as $parameter) { |
||
77 | $integerList->add($parameter); |
||
78 | } |
||
79 | } catch (\Exception $exception) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
80 | } |
||
81 | |||
82 | $this->assertInstanceOf(InvalidTypeException::class, $exception); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @test |
||
87 | * @dataProvider getValidParameters |
||
88 | */ |
||
89 | public function set_validParameters_noExceptions(array $parameters): void |
||
90 | { |
||
91 | $integerList = $this->createList(); |
||
92 | $exception = null; |
||
93 | |||
94 | try { |
||
95 | foreach ($parameters as $parameter) { |
||
96 | $integerList->set(0, $parameter); |
||
97 | } |
||
98 | } catch (\Exception $exception) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
99 | } |
||
100 | |||
101 | $this->assertInstanceOf($this->getListClassName(), $integerList); |
||
102 | $this->assertNull($exception); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @test |
||
107 | * @dataProvider getInvalidParameters |
||
108 | */ |
||
109 | View Code Duplication | public function set_invalidParameters_noExceptions(array $parameters): void |
|
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. ![]() |
|||
110 | { |
||
111 | $integerList = $this->createList(); |
||
112 | $exception = null; |
||
113 | |||
114 | try { |
||
115 | foreach ($parameters as $parameter) { |
||
116 | $integerList->set(0, $parameter); |
||
117 | } |
||
118 | } catch (\Exception $exception) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
119 | } |
||
120 | |||
121 | $this->assertInstanceOf(InvalidTypeException::class, $exception); |
||
122 | } |
||
123 | |||
124 | protected function createList(array $parameters = []): AbstractTypedList |
||
125 | { |
||
126 | $className = $this->getListClassName(); |
||
127 | |||
128 | return new $className($parameters); |
||
129 | } |
||
130 | |||
131 | abstract protected function getListClassName(): string; |
||
132 | } |
||
133 |