diff --git a/src/MountManagerTest.php b/src/MountManagerTest.php index cde9ebd0c..108d6da94 100644 --- a/src/MountManagerTest.php +++ b/src/MountManagerTest.php @@ -54,6 +54,50 @@ protected function setUp(): void ]); } + /** + * @test + */ + public function copying_without_retaining_visibility(): void + { + // arrange + $firstFilesystemAdapter = new InMemoryFilesystemAdapter(); + $secondFilesystemAdapter = new InMemoryFilesystemAdapter(); + $mountManager = new MountManager([ + 'first' => new Filesystem($firstFilesystemAdapter, ['visibility' => 'public']), + 'second' => new Filesystem($secondFilesystemAdapter, ['visibility' => 'private']), + ], ['retain_visibility' => false]); + + // act + $mountManager->write('first://file.txt', 'contents'); + $mountManager->copy('first://file.txt', 'second://file.txt'); + + // assert + $visibility = $mountManager->visibility('second://file.txt'); + self::assertEquals('private', $visibility); + } + + /** + * @test + */ + public function copying_while_retaining_visibility(): void + { + // arrange + $firstFilesystemAdapter = new InMemoryFilesystemAdapter(); + $secondFilesystemAdapter = new InMemoryFilesystemAdapter(); + $mountManager = new MountManager([ + 'first' => new Filesystem($firstFilesystemAdapter, ['visibility' => 'public']), + 'second' => new Filesystem($secondFilesystemAdapter, ['visibility' => 'private']), + ], ['retain_visibility' => true]); + + // act + $mountManager->write('first://file.txt', 'contents'); + $mountManager->copy('first://file.txt', 'second://file.txt'); + + // assert + $visibility = $mountManager->visibility('second://file.txt'); + self::assertEquals('public', $visibility); + } + /** * @test */