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 KochTest\Cache; |
||
4 | |||
5 | use Koch\Cache\Adapter\File; |
||
6 | |||
7 | class AbstractCacheTest extends \PHPUnit_Framework_TestCase |
||
8 | { |
||
9 | /** |
||
10 | * @var AbstractCache |
||
11 | */ |
||
12 | protected $object; |
||
13 | |||
14 | /** |
||
15 | * Sets up the fixture, for example, opens a network connection. |
||
16 | * This method is called before a test is executed. |
||
17 | */ |
||
18 | public function setUp() |
||
19 | { |
||
20 | // we are using the cache adapter File here, |
||
21 | // it's a class extending the abstract class |
||
22 | // abstract classes cannot be instantiated |
||
23 | $this->object = new File(); |
||
0 ignored issues
–
show
|
|||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Tears down the fixture, for example, closes a network connection. |
||
28 | * This method is called after a test is executed. |
||
29 | */ |
||
30 | public function tearDown() |
||
31 | { |
||
32 | unset($this->object); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @covers Koch\Cache\AbstractCache::__construct |
||
37 | * @covers Koch\Autoload\Loader::autoload |
||
38 | */ |
||
39 | public function testConstructor() |
||
40 | { |
||
41 | unset($this->object); |
||
42 | |||
43 | $options = ['prefix' => 'value']; |
||
44 | $this->object = new File($options); |
||
0 ignored issues
–
show
It seems like
new \Koch\Cache\Adapter\File($options) of type object<Koch\Cache\Adapter\File> is incompatible with the declared type object<KochTest\Cache\AbstractCache> of property $object .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
45 | |||
46 | $this->assertEquals('value', $this->object->options['prefix']); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @covers Koch\Cache\AbstractCache::setOptions |
||
51 | * @covers Koch\Cache\AbstractCache::setOption |
||
52 | */ |
||
53 | public function testSetOptions() |
||
54 | { |
||
55 | $options = [ |
||
56 | 'prefix' => 'someprefix', |
||
57 | 'ttl' => 1337, |
||
58 | ]; |
||
59 | $this->object->setOptions($options); |
||
60 | |||
61 | $this->assertEquals('someprefix', $this->object->options['prefix']); |
||
62 | $this->assertEquals(1337, $this->object->options['ttl']); |
||
63 | } |
||
64 | |||
65 | public static function SetOptionDataprovider() |
||
0 ignored issues
–
show
function SetOptionDataprovider() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
66 | { |
||
67 | return [ |
||
68 | ['prefix', 'some-prefix'], |
||
69 | ['ttl', 1337], |
||
70 | ]; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @covers Koch\Cache\AbstractCache::setOption |
||
75 | * @dataProvider SetOptionDataprovider |
||
76 | */ |
||
77 | public function testSetOption($key, $value) |
||
78 | { |
||
79 | $this->object->setOption($key, $value); |
||
80 | $this->assertEquals($this->object->options[$key], $value); |
||
81 | } |
||
82 | |||
83 | public static function SetOptionDataproviderInvalidData() |
||
0 ignored issues
–
show
function SetOptionDataproviderInvalidData() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
84 | { |
||
85 | return [ |
||
86 | ['prefix', ''], |
||
87 | ['ttl', -1], |
||
88 | ['unknown', 'unknown'], |
||
89 | ]; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @covers Koch\Cache\AbstractCache::setOption |
||
94 | * @covers Koch\Cache\AbstractCache::setOptions |
||
95 | * @dataProvider SetOptionDataproviderInvalidData |
||
96 | * @expectedException InvalidArgumentException |
||
97 | */ |
||
98 | public function testSetOption_throwsException($key, $value) |
||
0 ignored issues
–
show
function testSetOption_throwsException() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
99 | { |
||
100 | $this->object->setOption($key, $value); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @covers Koch\Cache\AbstractCache::setPrefix |
||
105 | * @covers Koch\Cache\AbstractCache::getPrefix |
||
106 | */ |
||
107 | public function testSetPrefix() |
||
108 | { |
||
109 | $prefix = 'newPrefix'; |
||
110 | $this->object->setPrefix($prefix); |
||
111 | $this->assertEquals($prefix, $this->object->getPrefix()); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @covers Koch\Cache\AbstractCache::setPrefix |
||
116 | * @expectedException \InvalidArgumentException |
||
117 | * @expectedExceptionMessage Prefix must not be empty. |
||
118 | */ |
||
119 | public function testSetPrefix_throwsException() |
||
0 ignored issues
–
show
function testSetPrefix_throwsException() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
120 | { |
||
121 | $this->object->setPrefix(''); |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * @covers Koch\Cache\AbstractCache::prefixKey |
||
126 | */ |
||
127 | public function testApplyPrefix() |
||
128 | { |
||
129 | $this->object->setPrefix('newPrefix'); |
||
130 | |||
131 | $key = 'Key'; |
||
132 | $this->assertEquals('newPrefixKey', $this->object->prefixKey($key)); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * @covers Koch\Cache\AbstractCache::__set |
||
137 | * @covers Koch\Cache\AbstractCache::__isset |
||
138 | * @covers Koch\Cache\AbstractCache::__get |
||
139 | * @covers Koch\Cache\AbstractCache::__unset |
||
140 | */ |
||
141 | View Code Duplication | public function testSet() |
|
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. ![]() |
|||
142 | { |
||
143 | // set |
||
144 | $this->object->key = 'value'; |
||
145 | // isset |
||
146 | $this->assertTrue(isset($this->object->key)); |
||
147 | // get |
||
148 | $this->assertEquals('value', $this->object->key); |
||
149 | // unset |
||
150 | unset($this->object->key); |
||
151 | $this->assertFalse(isset($this->object->key)); |
||
152 | } |
||
153 | } |
||
154 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..