@@ -347,6 +347,86 @@ public function testReadThroughDisksDoNotResurrectMovedFiles()
347347 $ this ->assertTrue ($ readThrough ->missing ('source.txt ' ));
348348 }
349349
350+ public function testReadThroughDisksMoveFilesThatOnlyExistOnTheFallbackDisk ()
351+ {
352+ $ filesystem = $ this ->readThroughFilesystemManager ();
353+ $ primary = $ filesystem ->disk ('primary ' );
354+ $ fallback = $ filesystem ->disk ('fallback ' );
355+ $ readThrough = $ filesystem ->disk ('read-through ' );
356+
357+ $ fallback ->put ('source.txt ' , 'contents ' );
358+
359+ $ this ->assertTrue ($ readThrough ->move ('source.txt ' , 'destination.txt ' ));
360+ $ this ->assertSame ('contents ' , $ primary ->get ('destination.txt ' ));
361+ $ this ->assertTrue ($ fallback ->missing ('source.txt ' ));
362+ $ this ->assertTrue ($ readThrough ->missing ('source.txt ' ));
363+ }
364+
365+ public function testReadThroughDisksCopyFilesThatOnlyExistOnTheFallbackDisk ()
366+ {
367+ $ filesystem = $ this ->readThroughFilesystemManager ();
368+ $ primary = $ filesystem ->disk ('primary ' );
369+ $ fallback = $ filesystem ->disk ('fallback ' );
370+ $ readThrough = $ filesystem ->disk ('read-through ' );
371+
372+ $ fallback ->put ('source.txt ' , 'contents ' );
373+
374+ $ this ->assertTrue ($ readThrough ->copy ('source.txt ' , 'destination.txt ' ));
375+ $ this ->assertSame ('contents ' , $ primary ->get ('destination.txt ' ));
376+ $ this ->assertSame ('contents ' , $ fallback ->get ('source.txt ' ));
377+ $ this ->assertSame ('contents ' , $ readThrough ->get ('source.txt ' ));
378+ }
379+
380+ public function testReadThroughDisksCopyFromTheFallbackDiskWithoutPromotingTheSourceWhenDisabled ()
381+ {
382+ $ filesystem = $ this ->readThroughFilesystemManager ([
383+ 'copy ' => false ,
384+ ]);
385+ $ primary = $ filesystem ->disk ('primary ' );
386+ $ fallback = $ filesystem ->disk ('fallback ' );
387+ $ readThrough = $ filesystem ->disk ('read-through ' );
388+
389+ $ fallback ->put ('source.txt ' , 'contents ' );
390+
391+ $ this ->assertTrue ($ readThrough ->copy ('source.txt ' , 'destination.txt ' ));
392+ $ this ->assertSame ('contents ' , $ primary ->get ('destination.txt ' ));
393+ $ this ->assertTrue ($ primary ->missing ('source.txt ' ));
394+ $ this ->assertSame ('contents ' , $ fallback ->get ('source.txt ' ));
395+
396+ $ this ->assertTrue ($ readThrough ->move ('source.txt ' , 'moved.txt ' ));
397+ $ this ->assertSame ('contents ' , $ primary ->get ('moved.txt ' ));
398+ $ this ->assertTrue ($ primary ->missing ('source.txt ' ));
399+ $ this ->assertTrue ($ fallback ->missing ('source.txt ' ));
400+ }
401+
402+ public function testReadThroughDisksFailToMoveOrCopyMissingFiles ()
403+ {
404+ $ filesystem = $ this ->readThroughFilesystemManager ();
405+ $ readThrough = $ filesystem ->disk ('read-through ' );
406+
407+ $ this ->assertFalse ($ readThrough ->move ('missing.txt ' , 'destination.txt ' ));
408+ $ this ->assertFalse ($ readThrough ->copy ('missing.txt ' , 'destination.txt ' ));
409+ }
410+
411+ public function testReadThroughDisksFailToMoveOrCopyWhenThePrimaryDiskIsUnwritable ()
412+ {
413+ $ filesystem = $ this ->readThroughFilesystemManager ([
414+ 'primary ' => [
415+ 'driver ' => 'local ' ,
416+ 'root ' => $ this ->temporaryDirectory ('primary ' ),
417+ 'read-only ' => true ,
418+ ],
419+ ]);
420+ $ fallback = $ filesystem ->disk ('fallback ' );
421+ $ readThrough = $ filesystem ->disk ('read-through ' );
422+
423+ $ fallback ->put ('source.txt ' , 'contents ' );
424+
425+ $ this ->assertFalse ($ readThrough ->move ('source.txt ' , 'destination.txt ' ));
426+ $ this ->assertFalse ($ readThrough ->copy ('source.txt ' , 'destination.txt ' ));
427+ $ this ->assertSame ('contents ' , $ fallback ->get ('source.txt ' ));
428+ }
429+
350430 public function testReadThroughDiskPromotionFailuresAreBestEffortByDefault ()
351431 {
352432 $ filesystem = $ this ->readThroughFilesystemManager ([
0 commit comments