From 99b04f59596d725c45a19508854577a238f89e97 Mon Sep 17 00:00:00 2001 From: Derek MacDonald Date: Thu, 3 Mar 2022 10:33:01 -0500 Subject: [PATCH] Test FilesystemAdapter::put() exceptions in Windows environment (#41323) Instead of attempting a write to a read-only directory, use a read-only file which is supported on Windows OS. --- tests/Filesystem/FilesystemAdapterTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/Filesystem/FilesystemAdapterTest.php b/tests/Filesystem/FilesystemAdapterTest.php index f125edbe74ba..1e8d55bbeb6a 100644 --- a/tests/Filesystem/FilesystemAdapterTest.php +++ b/tests/Filesystem/FilesystemAdapterTest.php @@ -396,7 +396,7 @@ public function testTemporaryUrlWithCustomCallback() ); } - public function testThrowExceptionForGet() + public function testThrowExceptionsForGet() { $adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]); @@ -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.');