1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SubjectivePHPTest\Psr\SimpleCache; |
4
|
|
|
|
5
|
|
|
use SubjectivePHP\Psr\SimpleCache\NullCache; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @coversDefaultClass SubjectivePHP\Psr\SimpleCache\NullCache |
9
|
|
|
* @covers ::<private> |
10
|
|
|
* @covers ::<protected> |
11
|
|
|
*/ |
12
|
|
|
final class NullCacheTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* NullCache instance to use in tests. |
16
|
|
|
* |
17
|
|
|
* @var NullCache |
18
|
|
|
*/ |
19
|
|
|
private $cache; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Prepare each test |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function setUp() |
27
|
|
|
{ |
28
|
|
|
$this->cache = new NullCache(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Verify basic behavior of get(). |
33
|
|
|
* |
34
|
|
|
* @test |
35
|
|
|
* @covers ::get |
36
|
|
|
* |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
public function get() |
40
|
|
|
{ |
41
|
|
|
$default = new \StdClass(); |
42
|
|
|
$this->assertSame($default, $this->cache->get('a key', $default)); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Verify basic behavior of set(). |
47
|
|
|
* |
48
|
|
|
* @test |
49
|
|
|
* @covers ::set |
50
|
|
|
* |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
|
|
public function set() |
54
|
|
|
{ |
55
|
|
|
$this->assertTrue($this->cache->set('a key', 'some data')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Verify basic behavior of delete(). |
60
|
|
|
* |
61
|
|
|
* @test |
62
|
|
|
* @covers ::delete |
63
|
|
|
* |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
|
public function delete() |
67
|
|
|
{ |
68
|
|
|
$this->assertTrue($this->cache->delete('a key')); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Verify basic behavior of clear(). |
73
|
|
|
* |
74
|
|
|
* @test |
75
|
|
|
* @covers ::clear |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
public function clear() |
80
|
|
|
{ |
81
|
|
|
$this->assertTrue($this->cache->clear()); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Verify basic behavior of getMultple(). |
86
|
|
|
* |
87
|
|
|
* @test |
88
|
|
|
* @covers ::getMultiple |
89
|
|
|
* |
90
|
|
|
* @return void |
91
|
|
|
*/ |
92
|
|
|
public function getMultiple() |
93
|
|
|
{ |
94
|
|
|
$default = new \StdClass(); |
95
|
|
|
$this->assertSame( |
96
|
|
|
['key1' => $default, 'key2' => $default], |
97
|
|
|
$this->cache->getMultiple(['key1', 'key2'], $default) |
|
|
|
|
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Verify basic behavior of setMultiple(). |
103
|
|
|
* |
104
|
|
|
* @test |
105
|
|
|
* @covers ::setMultiple |
106
|
|
|
* |
107
|
|
|
* @return void |
108
|
|
|
*/ |
109
|
|
|
public function setMultiple() |
110
|
|
|
{ |
111
|
|
|
$this->assertTrue($this->cache->setMultiple(['key' => 'some data', 'key2' => 'some more data'])); |
|
|
|
|
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Verify basic behavior of deleteMultiple(). |
116
|
|
|
* |
117
|
|
|
* @test |
118
|
|
|
* @covers ::deleteMultiple |
119
|
|
|
* |
120
|
|
|
* @return void |
121
|
|
|
*/ |
122
|
|
|
public function deleteMultiple() |
123
|
|
|
{ |
124
|
|
|
$this->assertTrue($this->cache->deleteMultiple(['key1', 'key2'])); |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Verify basic behavior of has(). |
129
|
|
|
* |
130
|
|
|
* @test |
131
|
|
|
* @covers ::has |
132
|
|
|
* |
133
|
|
|
* @return void |
134
|
|
|
*/ |
135
|
|
|
public function has() |
136
|
|
|
{ |
137
|
|
|
$this->assertFalse($this->cache->has('key1')); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
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: