1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace StorageDirsTests; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use CommonTestClass; |
7
|
|
|
use kalanis\kw_files\Interfaces\IProcessDirs; |
8
|
|
|
use kalanis\kw_files\Interfaces\IProcessFiles; |
9
|
|
|
use kalanis\kw_files\Interfaces\IProcessNodes; |
10
|
|
|
use kalanis\kw_files\Processing\Storage\ProcessDir; |
11
|
|
|
use kalanis\kw_files\Processing\Storage\ProcessFile; |
12
|
|
|
use kalanis\kw_files\Processing\Storage\ProcessNode; |
13
|
|
|
use kalanis\kw_storage\Storage\Key\DirKey; |
14
|
|
|
use kalanis\kw_storage\Storage\StorageDirs; |
15
|
|
|
use kalanis\kw_storage\Storage\Target\Volume; |
16
|
|
|
use kalanis\kw_storage\StorageException; |
17
|
|
|
use Traversable; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
abstract class AStorageTest extends CommonTestClass |
21
|
|
|
{ |
22
|
|
|
protected function getNodeLib(): IProcessNodes |
23
|
|
|
{ |
24
|
|
|
DirKey::setDir($this->getTestPath()); |
25
|
|
|
return new ProcessNode(new StorageDirs(new DirKey(), new Volume())); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
protected function getNodeFailLib(): IProcessNodes |
29
|
|
|
{ |
30
|
|
|
DirKey::setDir($this->getTestPath()); |
31
|
|
|
return new ProcessNode(new XFailStorageDirs(new DirKey(), new Volume())); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function getFileLib(): IProcessFiles |
35
|
|
|
{ |
36
|
|
|
DirKey::setDir($this->getTestPath()); |
37
|
|
|
return new ProcessFile(new StorageDirs(new DirKey(), new Volume())); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
protected function getFileFailLib(): IProcessFiles |
41
|
|
|
{ |
42
|
|
|
DirKey::setDir($this->getTestPath()); |
43
|
|
|
return new ProcessFile(new XFailStorageDirs(new DirKey(), new Volume())); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
protected function getDirLib(): IProcessDirs |
47
|
|
|
{ |
48
|
|
|
DirKey::setDir($this->getTestPath()); |
49
|
|
|
return new ProcessDir(new StorageDirs(new DirKey(), new Volume())); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function getDirFailLib(): IProcessDirs |
53
|
|
|
{ |
54
|
|
|
DirKey::setDir($this->getTestPath()); |
55
|
|
|
return new ProcessDir(new XFailStorageDirs(new DirKey(), new Volume())); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function getTestPath(): string |
59
|
|
|
{ |
60
|
|
|
return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'tree'; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
class XFailStorageDirs extends StorageDirs |
66
|
|
|
{ |
67
|
|
|
public function write(string $sharedKey, $data, ?int $timeout = null): bool |
68
|
|
|
{ |
69
|
|
|
throw new StorageException('mock'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function read(string $sharedKey) |
73
|
|
|
{ |
74
|
|
|
throw new StorageException('mock'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function remove(string $sharedKey): bool |
78
|
|
|
{ |
79
|
|
|
throw new StorageException('mock'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function exists(string $sharedKey): bool |
83
|
|
|
{ |
84
|
|
|
throw new StorageException('mock'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function lookup(string $mask): Traversable |
88
|
|
|
{ |
89
|
|
|
throw new StorageException('mock'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function increment(string $key): bool |
93
|
|
|
{ |
94
|
|
|
throw new StorageException('mock'); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function decrement(string $key): bool |
98
|
|
|
{ |
99
|
|
|
throw new StorageException('mock'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function removeMulti(array $keys): array |
103
|
|
|
{ |
104
|
|
|
throw new StorageException('mock'); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function isDir(string $key): bool |
108
|
|
|
{ |
109
|
|
|
throw new StorageException('mock'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function isFile(string $key): bool |
113
|
|
|
{ |
114
|
|
|
throw new StorageException('mock'); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function isReadable(string $key): bool |
118
|
|
|
{ |
119
|
|
|
throw new StorageException('mock'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function isWritable(string $key): bool |
123
|
|
|
{ |
124
|
|
|
throw new StorageException('mock'); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function mkDir(string $key, bool $recursive = false): bool |
128
|
|
|
{ |
129
|
|
|
throw new StorageException('mock'); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function rmDir(string $key, bool $recursive = false): bool |
133
|
|
|
{ |
134
|
|
|
throw new StorageException('mock'); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function copy(string $source, string $dest): bool |
138
|
|
|
{ |
139
|
|
|
throw new StorageException('mock'); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function move(string $source, string $dest): bool |
143
|
|
|
{ |
144
|
|
|
throw new StorageException('mock'); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function size(string $key): ?int |
148
|
|
|
{ |
149
|
|
|
throw new StorageException('mock'); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function created(string $key): ?int |
153
|
|
|
{ |
154
|
|
|
throw new StorageException('mock'); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|