@@ -55,8 +55,7 @@ protected function tearDown(): void
55
55
public function testMove ()
56
56
{
57
57
$ finalFilename = 'fileA ' ;
58
-
59
- $ _FILES = [
58
+ $ _FILES = [
60
59
'userfile1 ' => [
61
60
'name ' => $ finalFilename . '.txt ' ,
62
61
'type ' => 'text/plain ' ,
@@ -79,7 +78,6 @@ public function testMove()
79
78
$ this ->assertTrue ($ collection ->hasFile ('userfile2 ' ));
80
79
81
80
$ destination = $ this ->destination ;
82
-
83
81
// Create the destination if not exists
84
82
if (! is_dir ($ destination )) {
85
83
mkdir ($ destination , 0777 , true );
@@ -97,8 +95,7 @@ public function testMove()
97
95
public function testMoveOverwriting ()
98
96
{
99
97
$ finalFilename = 'file_with_delimiters_underscore ' ;
100
-
101
- $ _FILES = [
98
+ $ _FILES = [
102
99
'userfile1 ' => [
103
100
'name ' => $ finalFilename . '.txt ' ,
104
101
'type ' => 'text/plain ' ,
@@ -129,7 +126,6 @@ public function testMoveOverwriting()
129
126
$ this ->assertTrue ($ collection ->hasFile ('userfile3 ' ));
130
127
131
128
$ destination = $ this ->destination ;
132
-
133
129
// Create the destination if not exists
134
130
if (! is_dir ($ destination )) {
135
131
mkdir ($ destination , 0777 , true );
@@ -149,8 +145,7 @@ public function testMoveOverwriting()
149
145
public function testMoved ()
150
146
{
151
147
$ finalFilename = 'fileA ' ;
152
-
153
- $ _FILES = [
148
+ $ _FILES = [
154
149
'userfile1 ' => [
155
150
'name ' => $ finalFilename . '.txt ' ,
156
151
'type ' => 'text/plain ' ,
@@ -165,7 +160,6 @@ public function testMoved()
165
160
$ this ->assertTrue ($ collection ->hasFile ('userfile1 ' ));
166
161
167
162
$ destination = $ this ->destination ;
168
-
169
163
// Create the destination if not exists
170
164
if (! is_dir ($ destination )) {
171
165
mkdir ($ destination , 0777 , true );
@@ -175,15 +169,16 @@ public function testMoved()
175
169
176
170
$ this ->assertInstanceOf (UploadedFile::class, $ file );
177
171
$ this ->assertFalse ($ file ->hasMoved ());
172
+
178
173
$ file ->move ($ destination , $ file ->getName (), false );
174
+
179
175
$ this ->assertTrue ($ file ->hasMoved ());
180
176
}
181
177
182
178
public function testStore ()
183
179
{
184
180
$ finalFilename = 'fileA ' ;
185
-
186
- $ _FILES = [
181
+ $ _FILES = [
187
182
'userfile1 ' => [
188
183
'name ' => $ finalFilename . '.txt ' ,
189
184
'type ' => 'text/plain ' ,
@@ -198,7 +193,6 @@ public function testStore()
198
193
$ this ->assertTrue ($ collection ->hasFile ('userfile1 ' ));
199
194
200
195
$ destination = $ this ->destination ;
201
-
202
196
// Create the destination if not exists
203
197
if (! is_dir ($ destination )) {
204
198
mkdir ($ destination , 0777 , true );
@@ -207,15 +201,16 @@ public function testStore()
207
201
$ file = $ collection ->getFile ('userfile1 ' );
208
202
209
203
$ this ->assertInstanceOf (UploadedFile::class, $ file );
204
+
210
205
$ path = $ file ->store ($ destination , $ file ->getName ());
206
+
211
207
$ this ->assertSame ($ destination . '/fileA.txt ' , $ path );
212
208
}
213
209
214
210
public function testAlreadyMoved ()
215
211
{
216
212
$ finalFilename = 'fileA ' ;
217
-
218
- $ _FILES = [
213
+ $ _FILES = [
219
214
'userfile1 ' => [
220
215
'name ' => $ finalFilename . '.txt ' ,
221
216
'type ' => 'text/plain ' ,
@@ -230,7 +225,6 @@ public function testAlreadyMoved()
230
225
$ this ->assertTrue ($ collection ->hasFile ('userfile1 ' ));
231
226
232
227
$ destination = $ this ->destination ;
233
-
234
228
// Create the destination if not exists
235
229
if (! is_dir ($ destination )) {
236
230
mkdir ($ destination , 0777 , true );
@@ -257,11 +251,11 @@ public function testInvalidFile()
257
251
];
258
252
259
253
$ destination = $ this ->destination ;
260
-
261
- $ collection = new FileCollection ();
262
- $ file = $ collection ->getFile ('userfile ' );
254
+ $ collection = new FileCollection ();
263
255
264
256
$ this ->expectException (HTTPException::class);
257
+
258
+ $ file = $ collection ->getFile ('userfile ' );
265
259
$ file ->move ($ destination , $ file ->getName (), false );
266
260
}
267
261
@@ -278,16 +272,16 @@ public function testFailedMoveBecauseOfWarning()
278
272
];
279
273
280
274
$ destination = $ this ->destination ;
281
-
282
275
// Create the destination and make it read only
283
276
if (! is_dir ($ destination )) {
284
277
mkdir ($ destination , 0400 , true );
285
278
}
286
279
287
280
$ collection = new FileCollection ();
288
- $ file = $ collection ->getFile ('userfile ' );
289
281
290
282
$ this ->expectException (HTTPException::class);
283
+
284
+ $ file = $ collection ->getFile ('userfile ' );
291
285
$ file ->move ($ destination , $ file ->getName (), false );
292
286
}
293
287
@@ -308,20 +302,17 @@ public function testFailedMoveBecauseOfFalseReturned()
308
302
$ this ->assertTrue ($ collection ->hasFile ('userfile1 ' ));
309
303
310
304
$ destination = $ this ->destination ;
311
-
312
305
// Create the destination if not exists
313
306
if (! is_dir ($ destination )) {
314
307
mkdir ($ destination , 0777 , true );
315
308
}
316
-
317
- $ file = $ collection ->getFile ('userfile1 ' );
318
-
319
309
// Set the mock's return value to false
320
310
move_uploaded_file ('' , '' , false );
321
311
322
312
$ this ->expectException (HTTPException::class);
323
313
$ this ->expectExceptionMessage ('move_uploaded_file() returned false ' );
324
314
315
+ $ file = $ collection ->getFile ('userfile1 ' );
325
316
$ file ->move ($ destination , $ file ->getName (), false );
326
317
}
327
318
}
0 commit comments