Skip to content

Commit

Permalink
Tested MountManager for not retaining visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Nov 2, 2023
1 parent d15165f commit b015995
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/MountManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit b015995

Please sign in to comment.