@@ -282,7 +282,7 @@ public function test_it_throws_an_exception_if_moving_to_existing_file()
282
282
$ media1 ->move ('' , 'bar.baz ' );
283
283
}
284
284
285
- public function test_it_can_be_moved_to_another_disk ()
285
+ public function test_it_can_be_moved_to_another_disk_public ()
286
286
{
287
287
$ this ->useFilesystem ('tmp ' );
288
288
$ this ->useFilesystem ('uploads ' );
@@ -297,15 +297,72 @@ public function test_it_can_be_moved_to_another_disk()
297
297
]);
298
298
$ original_path = $ media ->getAbsolutePath ();
299
299
$ this ->seedFileForMedia ($ media );
300
+ $ media ->makePublic ();
301
+
302
+ $ media ->moveToDisk ('uploads ' , 'alpha/beta ' , 'gamma ' );
303
+ $ this ->assertEquals ('uploads ' , $ media ->disk );
304
+ $ this ->assertEquals ('alpha/beta/gamma.baz ' , $ media ->getDiskPath ());
305
+ $ this ->assertTrue ($ media ->fileExists ());
306
+ $ this ->assertFalse (file_exists ($ original_path ));
307
+ $ this ->assertTrue ($ media ->isVisible ());
308
+ }
309
+
310
+ public function test_it_can_be_moved_to_another_disk_private ()
311
+ {
312
+ $ this ->useFilesystem ('tmp ' );
313
+ $ this ->useFilesystem ('uploads ' );
314
+
315
+ $ this ->useDatabase ();
316
+
317
+ $ media = $ this ->makeMedia ([
318
+ 'disk ' => 'tmp ' ,
319
+ 'directory ' => 'foo ' ,
320
+ 'filename ' => 'bar ' ,
321
+ 'extension ' => 'baz '
322
+ ]);
323
+ $ original_path = $ media ->getAbsolutePath ();
324
+ $ this ->seedFileForMedia ($ media );
325
+ $ media ->makePrivate ();
300
326
301
327
$ media ->moveToDisk ('uploads ' , 'alpha/beta ' , 'gamma ' );
302
328
$ this ->assertEquals ('uploads ' , $ media ->disk );
303
329
$ this ->assertEquals ('alpha/beta/gamma.baz ' , $ media ->getDiskPath ());
304
330
$ this ->assertTrue ($ media ->fileExists ());
305
331
$ this ->assertFalse (file_exists ($ original_path ));
332
+ $ this ->assertFalse ($ media ->isVisible ());
333
+ }
334
+
335
+ public function test_it_can_be_copied_to_another_disk_public ()
336
+ {
337
+ $ this ->useFilesystem ('tmp ' );
338
+ $ this ->useFilesystem ('uploads ' );
339
+
340
+ $ this ->useDatabase ();
341
+
342
+ $ media = $ this ->makeMedia ([
343
+ 'disk ' => 'tmp ' ,
344
+ 'directory ' => 'foo ' ,
345
+ 'filename ' => 'bar ' ,
346
+ 'extension ' => 'baz '
347
+ ]);
348
+ $ original_path = $ media ->getAbsolutePath ();
349
+ $ this ->seedFileForMedia ($ media );
350
+ $ media ->makePublic ();
351
+
352
+ $ newMedia = $ media ->copyToDisk ('uploads ' , 'alpha/beta ' , 'gamma ' );
353
+ $ this ->assertEquals ('uploads ' , $ newMedia ->disk );
354
+ $ this ->assertEquals ('alpha/beta/gamma.baz ' , $ newMedia ->getDiskPath ());
355
+ $ this ->assertTrue ($ newMedia ->fileExists ());
356
+ $ this ->assertTrue ($ newMedia ->isVisible ());
357
+
358
+ //original should be unchanged
359
+ $ this ->assertEquals ('tmp ' , $ media ->disk );
360
+ $ this ->assertEquals ('foo/bar.baz ' , $ media ->getDiskPath ());
361
+ $ this ->assertTrue ($ media ->fileExists ());
362
+ $ this ->assertTrue ($ media ->isVisible ());
306
363
}
307
364
308
- public function test_it_can_be_copied_to_another_disk ()
365
+ public function test_it_can_be_copied_to_another_disk_private ()
309
366
{
310
367
$ this ->useFilesystem ('tmp ' );
311
368
$ this ->useFilesystem ('uploads ' );
@@ -320,16 +377,19 @@ public function test_it_can_be_copied_to_another_disk()
320
377
]);
321
378
$ original_path = $ media ->getAbsolutePath ();
322
379
$ this ->seedFileForMedia ($ media );
380
+ $ media ->makePrivate ();
323
381
324
382
$ newMedia = $ media ->copyToDisk ('uploads ' , 'alpha/beta ' , 'gamma ' );
325
383
$ this ->assertEquals ('uploads ' , $ newMedia ->disk );
326
384
$ this ->assertEquals ('alpha/beta/gamma.baz ' , $ newMedia ->getDiskPath ());
327
385
$ this ->assertTrue ($ newMedia ->fileExists ());
386
+ $ this ->assertFalse ($ newMedia ->isVisible ());
328
387
329
388
//original should be unchanged
330
389
$ this ->assertEquals ('tmp ' , $ media ->disk );
331
390
$ this ->assertEquals ('foo/bar.baz ' , $ media ->getDiskPath ());
332
391
$ this ->assertTrue ($ media ->fileExists ());
392
+ $ this ->assertFalse ($ media ->isVisible ());
333
393
}
334
394
335
395
public function test_it_can_access_file_contents ()
0 commit comments