1 | <?php |
||
2 | |||
3 | namespace CacheTests; |
||
4 | |||
5 | |||
6 | use kalanis\kw_cache\CacheException; |
||
7 | use kalanis\kw_cache\Interfaces\ICache; |
||
8 | use kalanis\kw_storage\Interfaces\IStorage; |
||
9 | use kalanis\kw_storage\Storage as XStorage; |
||
10 | |||
11 | |||
12 | abstract class ACacheTest extends \CommonTestClass |
||
13 | { |
||
14 | protected function getStorage(IStorage $mockStorage): XStorage\Storage |
||
15 | { |
||
16 | XStorage\Key\DirKey::setDir(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR); |
||
17 | $storage = new XStorage\Factory(new XStorage\Key\Factory(), new XStorage\Target\Factory()); |
||
18 | return $storage->getStorage($mockStorage); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
19 | } |
||
20 | } |
||
21 | |||
22 | |||
23 | class MockCacheFail implements ICache |
||
24 | { |
||
25 | public function init(string $what): void |
||
26 | { |
||
27 | } |
||
28 | |||
29 | public function exists(): bool |
||
30 | { |
||
31 | return false; |
||
32 | } |
||
33 | |||
34 | public function set(string $content): bool |
||
35 | { |
||
36 | return false; |
||
37 | } |
||
38 | |||
39 | public function get(): string |
||
40 | { |
||
41 | return ''; |
||
42 | } |
||
43 | |||
44 | public function clear(): void |
||
45 | { |
||
46 | } |
||
47 | } |
||
48 | |||
49 | |||
50 | class MockCacheKill implements ICache |
||
51 | { |
||
52 | public function init(string $what): void |
||
53 | { |
||
54 | } |
||
55 | |||
56 | public function exists(): bool |
||
57 | { |
||
58 | return true; |
||
59 | } |
||
60 | |||
61 | public function set(string $content): bool |
||
62 | { |
||
63 | return true; |
||
64 | } |
||
65 | |||
66 | public function get(): string |
||
67 | { |
||
68 | return ''; |
||
69 | } |
||
70 | |||
71 | public function clear(): void |
||
72 | { |
||
73 | throw new CacheException('mock test'); |
||
74 | } |
||
75 | } |
||
76 |