1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MapperTests; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\kw_files\FilesException; |
7
|
|
|
use kalanis\kw_mapper\MapperException; |
8
|
|
|
use kalanis\kw_paths\PathsException; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class StreamFailTest extends AStorageTest |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @throws FilesException |
15
|
|
|
* @throws MapperException |
16
|
|
|
* @throws PathsException |
17
|
|
|
*/ |
18
|
|
|
public function testRead(): void |
19
|
|
|
{ |
20
|
|
|
if ($this->skipIt) { |
21
|
|
|
$this->markTestSkipped('Skipped by config'); |
22
|
|
|
return; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$this->dataRefill(); |
26
|
|
|
|
27
|
|
|
$lib = $this->getStreamFailLib(); |
28
|
|
|
$this->expectException(FilesException::class); |
29
|
|
|
$lib->readFileStream(['dummy2.txt']); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @throws FilesException |
34
|
|
|
* @throws MapperException |
35
|
|
|
* @throws PathsException |
36
|
|
|
*/ |
37
|
|
|
public function testSave(): void |
38
|
|
|
{ |
39
|
|
|
if ($this->skipIt) { |
40
|
|
|
$this->markTestSkipped('Skipped by config'); |
41
|
|
|
return; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$this->dataRefill(); |
45
|
|
|
|
46
|
|
|
$lib = $this->getStreamFailLib(); |
47
|
|
|
$this->expectException(FilesException::class); |
48
|
|
|
$lib->saveFileStream(['extra.txt'], $this->stringToStream('qwertzuiopasdfghjklyxcvbnm0123456789')); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @throws FilesException |
53
|
|
|
* @throws MapperException |
54
|
|
|
* @throws PathsException |
55
|
|
|
*/ |
56
|
|
|
public function testSave2(): void |
57
|
|
|
{ |
58
|
|
|
if ($this->skipIt) { |
59
|
|
|
$this->markTestSkipped('Skipped by config'); |
60
|
|
|
return; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$this->dataRefill(); |
64
|
|
|
|
65
|
|
|
$lib = $this->getStreamFailLib(); |
66
|
|
|
$this->expectException(FilesException::class); |
67
|
|
|
$lib->saveFileStream([], $this->stringToStream('qwertzuiopasdfghjklyxcvbnm0123456789')); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @throws FilesException |
72
|
|
|
* @throws MapperException |
73
|
|
|
* @throws PathsException |
74
|
|
|
*/ |
75
|
|
|
public function testSave3(): void |
76
|
|
|
{ |
77
|
|
|
if ($this->skipIt) { |
78
|
|
|
$this->markTestSkipped('Skipped by config'); |
79
|
|
|
return; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$this->dataRefill(); |
83
|
|
|
|
84
|
|
|
$lib = $this->getStreamLib(); |
85
|
|
|
$this->expectException(FilesException::class); |
86
|
|
|
$lib->saveFileStream(['not existent', 'directory', 'with file'], $this->stringToStream('qwertzuiopasdfghjklyxcvbnm0123456789')); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @throws FilesException |
91
|
|
|
* @throws MapperException |
92
|
|
|
* @throws PathsException |
93
|
|
|
*/ |
94
|
|
|
public function testSave4(): void |
95
|
|
|
{ |
96
|
|
|
if ($this->skipIt) { |
97
|
|
|
$this->markTestSkipped('Skipped by config'); |
98
|
|
|
return; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
$this->dataRefill(); |
102
|
|
|
|
103
|
|
|
$lib = $this->getStreamFailRecLib(); |
104
|
|
|
$this->expectException(FilesException::class); |
105
|
|
|
$lib->saveFileStream(['possible file'], $this->stringToStream('qwertzuiopasdfghjklyxcvbnm0123456789')); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @throws FilesException |
110
|
|
|
* @throws MapperException |
111
|
|
|
* @throws PathsException |
112
|
|
|
*/ |
113
|
|
|
public function testCopy(): void |
114
|
|
|
{ |
115
|
|
|
if ($this->skipIt) { |
116
|
|
|
$this->markTestSkipped('Skipped by config'); |
117
|
|
|
return; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
$this->dataRefill(); |
121
|
|
|
|
122
|
|
|
$lib = $this->getStreamFailLib(); |
123
|
|
|
$this->expectException(FilesException::class); |
124
|
|
|
$lib->copyFileStream(['dummy2.txt'], ['extra1.txt']); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @throws FilesException |
129
|
|
|
* @throws MapperException |
130
|
|
|
* @throws PathsException |
131
|
|
|
*/ |
132
|
|
|
public function testCopyToExisting(): void |
133
|
|
|
{ |
134
|
|
|
if ($this->skipIt) { |
135
|
|
|
$this->markTestSkipped('Skipped by config'); |
136
|
|
|
return; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
$this->dataRefill(); |
140
|
|
|
|
141
|
|
|
$lib = $this->getStreamLib(); |
142
|
|
|
$this->assertFalse($lib->copyFileStream(['dummy2.txt'], ['dummy1.txt'])); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @throws FilesException |
147
|
|
|
* @throws MapperException |
148
|
|
|
* @throws PathsException |
149
|
|
|
*/ |
150
|
|
|
public function testMove(): void |
151
|
|
|
{ |
152
|
|
|
if ($this->skipIt) { |
153
|
|
|
$this->markTestSkipped('Skipped by config'); |
154
|
|
|
return; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
$this->dataRefill(); |
158
|
|
|
|
159
|
|
|
$lib = $this->getStreamFailLib(); |
160
|
|
|
$this->expectException(FilesException::class); |
161
|
|
|
$lib->moveFileStream(['extra1.txt'], ['extra2.txt']); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @throws FilesException |
166
|
|
|
* @throws MapperException |
167
|
|
|
* @throws PathsException |
168
|
|
|
*/ |
169
|
|
|
public function testMoveUnknown(): void |
170
|
|
|
{ |
171
|
|
|
if ($this->skipIt) { |
172
|
|
|
$this->markTestSkipped('Skipped by config'); |
173
|
|
|
return; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
$this->dataRefill(); |
177
|
|
|
|
178
|
|
|
$lib = $this->getStreamLib(); |
179
|
|
|
$this->expectException(FilesException::class); |
180
|
|
|
$lib->moveFileStream(['not source.txt'], ['extra2.txt']); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @throws FilesException |
185
|
|
|
* @throws MapperException |
186
|
|
|
* @throws PathsException |
187
|
|
|
*/ |
188
|
|
|
public function testMoveToUnknownDir(): void |
189
|
|
|
{ |
190
|
|
|
if ($this->skipIt) { |
191
|
|
|
$this->markTestSkipped('Skipped by config'); |
192
|
|
|
return; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
$this->dataRefill(); |
196
|
|
|
|
197
|
|
|
$lib = $this->getStreamLib(); |
198
|
|
|
$this->assertFalse($lib->moveFileStream(['sub', 'dummy3.txt'], ['whatabout', 'other2.txt'])); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @throws FilesException |
203
|
|
|
* @throws MapperException |
204
|
|
|
* @throws PathsException |
205
|
|
|
*/ |
206
|
|
|
public function testMoveToExisting(): void |
207
|
|
|
{ |
208
|
|
|
if ($this->skipIt) { |
209
|
|
|
$this->markTestSkipped('Skipped by config'); |
210
|
|
|
return; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
$this->dataRefill(); |
214
|
|
|
|
215
|
|
|
$lib = $this->getStreamLib(); |
216
|
|
|
$this->assertFalse($lib->moveFileStream(['sub', 'dummy3.txt'], ['other2.txt'])); |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
|