1 | <?php |
||
12 | class TestCacheDecorator extends CacheDecorator |
||
13 | { |
||
14 | /** |
||
15 | * Calls made to the cache |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private $calls = [ |
||
20 | 'delete' => [], |
||
21 | 'set' => [], |
||
22 | 'has' => [], |
||
23 | 'get' => [], |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * Checks if an item has been deleted |
||
28 | * |
||
29 | * @param string $key |
||
30 | * |
||
31 | * @return bool |
||
32 | */ |
||
33 | public function hasBeenDeleted($key) |
||
37 | |||
38 | /** |
||
39 | * Checks if an item has been requested with 'get' or 'pull' |
||
40 | * |
||
41 | * @param string $key |
||
42 | * |
||
43 | * @return bool |
||
44 | */ |
||
45 | public function hasBeenRetrieved($key) |
||
49 | |||
50 | /** |
||
51 | * Checks if an item has been checked with the 'has' method |
||
52 | * |
||
53 | * @param string $key |
||
54 | * |
||
55 | * @return bool |
||
56 | */ |
||
57 | public function hasBeenChecked($key) |
||
61 | |||
62 | /** |
||
63 | * Checks if an item has been set |
||
64 | * |
||
65 | * @param string $key |
||
66 | * @param mixed $value |
||
67 | * @param int|null $timeToLive |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function hasBeenSet($key, $value = null, $timeToLive = null) |
||
81 | |||
82 | /** |
||
83 | * @return array |
||
84 | */ |
||
85 | public function getCalls() |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function delete($key) |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public function set($key, $value, $timeToLive = 0) |
||
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function has($key) |
||
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | public function get($key) |
||
133 | |||
134 | /** |
||
135 | * Tries to match a call by the key |
||
136 | * |
||
137 | * @param array $calls |
||
138 | * @param string $key |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | private function hasBeenDoneByKey(array $calls, $key) |
||
152 | |||
153 | /** |
||
154 | * @param array $set |
||
155 | * @param string $key |
||
156 | * @param mixed $value |
||
157 | * @param null|int $timeToLive |
||
158 | * |
||
159 | * @return bool |
||
160 | */ |
||
161 | private function callMatches(array $set, $key, $value = null, $timeToLive) |
||
173 | |||
174 | /** |
||
175 | * @param mixed $stored |
||
176 | * @param null $expected |
||
177 | * |
||
178 | * @return bool |
||
179 | */ |
||
180 | private function matches($stored, $expected = null) |
||
184 | } |
||
185 |