Skip to content

Commit

Permalink
Test FilesystemAdapter::put() exceptions in Windows environment (#41323)
Browse files Browse the repository at this point in the history
Instead of attempting a write to a read-only directory, use a read-only
file which is supported on Windows OS.
  • Loading branch information
derekmd committed Mar 3, 2022
1 parent c1c4404 commit 99b04f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/Filesystem/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function testTemporaryUrlWithCustomCallback()
);
}

public function testThrowExceptionForGet()
public function testThrowExceptionsForGet()
{
$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]);

Expand Down Expand Up @@ -426,19 +426,22 @@ public function testThrowExceptionsForReadStream()
$this->fail('Exception was not thrown.');
}

/** @requires OS Linux|Darwin */
public function testThrowExceptionsForPut()
{
mkdir(__DIR__.'/tmp/bar', 0600);
$this->filesystem->write('foo.txt', 'Hello World');

chmod(__DIR__.'/tmp/foo.txt', 0400);

$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]);

try {
$adapter->put('/bar/foo.txt', 'Hello World!');
$adapter->put('/foo.txt', 'Hello World!');
} catch (UnableToWriteFile $e) {
$this->assertTrue(true);

return;
} finally {
chmod(__DIR__.'/tmp/foo.txt', 0600);
}

$this->fail('Exception was not thrown.');
Expand Down

0 comments on commit 99b04f5

Please sign in to comment.