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; |
14
|
|
|
use kalanis\kw_storage\Storage\StorageDirs; |
15
|
|
|
use kalanis\kw_storage\Storage\Target; |
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
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
25
|
|
|
return new ProcessNode(new StorageDirs(new Key\DirKey(), new Target\Volume())); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
protected function getNodeFailLib(): IProcessNodes |
29
|
|
|
{ |
30
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
31
|
|
|
return new ProcessNode(new XFailStorageDirs(new Key\DirKey(), new Target\Volume())); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function getFileLib(): IProcessFiles |
35
|
|
|
{ |
36
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
37
|
|
|
return new ProcessFile(new StorageDirs(new Key\DirKey(), new Target\Volume())); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
protected function getFileFailLib(): IProcessFiles |
41
|
|
|
{ |
42
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
43
|
|
|
return new ProcessFile(new XFailStorageDirs(new Key\DirKey(), new Target\Volume())); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
protected function getDirRecursiveLib(): IProcessDirs |
47
|
|
|
{ |
48
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
49
|
|
|
return new ProcessDir(new StorageDirs(new Key\DirKey(), new Target\Volume())); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function getDirRecursiveFailLib(): IProcessDirs |
53
|
|
|
{ |
54
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
55
|
|
|
return new ProcessDir(new XFailStorageDirs(new Key\DirKey(), new Target\Volume())); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function getDirFlatLib(): IProcessDirs |
59
|
|
|
{ |
60
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
61
|
|
|
return new ProcessDir(new StorageDirs(new Key\DirKey(), new Target\VolumeTargetFlat())); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
protected function getDirFlatFailLib(): IProcessDirs |
65
|
|
|
{ |
66
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
67
|
|
|
return new ProcessDir(new XFailStorageDirs(new Key\DirKey(), new Target\VolumeTargetFlat())); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function getStorageRecursiveLib(): StorageDirs |
71
|
|
|
{ |
72
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
73
|
|
|
return new StorageDirs(new Key\DirKey(), new Target\Volume()); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
protected function getStorageFlatLib(): StorageDirs |
77
|
|
|
{ |
78
|
|
|
Key\DirKey::setDir($this->getTestPath()); |
79
|
|
|
return new StorageDirs(new Key\DirKey(), new Target\VolumeTargetFlat()); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
protected function getTestPath(): string |
83
|
|
|
{ |
84
|
|
|
return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'tree'; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
class XFailStorageDirs extends StorageDirs |
90
|
|
|
{ |
91
|
|
|
public function write(string $sharedKey, $data, ?int $timeout = null): bool |
92
|
|
|
{ |
93
|
|
|
throw new StorageException('mock'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function read(string $sharedKey) |
97
|
|
|
{ |
98
|
|
|
throw new StorageException('mock'); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function remove(string $sharedKey): bool |
102
|
|
|
{ |
103
|
|
|
throw new StorageException('mock'); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function exists(string $sharedKey): bool |
107
|
|
|
{ |
108
|
|
|
throw new StorageException('mock'); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
public function lookup(string $mask): Traversable |
112
|
|
|
{ |
113
|
|
|
throw new StorageException('mock'); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
public function increment(string $key): bool |
117
|
|
|
{ |
118
|
|
|
throw new StorageException('mock'); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function decrement(string $key): bool |
122
|
|
|
{ |
123
|
|
|
throw new StorageException('mock'); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function removeMulti(array $keys): array |
127
|
|
|
{ |
128
|
|
|
throw new StorageException('mock'); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function isDir(string $key): bool |
132
|
|
|
{ |
133
|
|
|
throw new StorageException('mock'); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function isFile(string $key): bool |
137
|
|
|
{ |
138
|
|
|
throw new StorageException('mock'); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function isReadable(string $key): bool |
142
|
|
|
{ |
143
|
|
|
throw new StorageException('mock'); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function isWritable(string $key): bool |
147
|
|
|
{ |
148
|
|
|
throw new StorageException('mock'); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function mkDir(string $key, bool $recursive = false): bool |
152
|
|
|
{ |
153
|
|
|
throw new StorageException('mock'); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
public function rmDir(string $key, bool $recursive = false): bool |
157
|
|
|
{ |
158
|
|
|
throw new StorageException('mock'); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function copy(string $source, string $dest): bool |
162
|
|
|
{ |
163
|
|
|
throw new StorageException('mock'); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
public function move(string $source, string $dest): bool |
167
|
|
|
{ |
168
|
|
|
throw new StorageException('mock'); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function size(string $key): ?int |
172
|
|
|
{ |
173
|
|
|
throw new StorageException('mock'); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function created(string $key): ?int |
177
|
|
|
{ |
178
|
|
|
throw new StorageException('mock'); |
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|