diff --git a/src/AdapterTestUtilities/FilesystemAdapterTestCase.php b/src/AdapterTestUtilities/FilesystemAdapterTestCase.php index 5361d30f4..c4bad0879 100644 --- a/src/AdapterTestUtilities/FilesystemAdapterTestCase.php +++ b/src/AdapterTestUtilities/FilesystemAdapterTestCase.php @@ -4,6 +4,7 @@ namespace League\Flysystem\AdapterTestUtilities; +use League\Flysystem\UnableToDeleteFile; use const PHP_EOL; use DateInterval; use DateTimeImmutable; @@ -871,4 +872,50 @@ public function cannot_get_checksum_for_directory(): void $adapter->checksum('dir', new Config()); } + + /** + * @test + */ + public function cannot_delete_directory_over_delete(): void + { + $this->runScenario(function () { + $adapter = $this->adapter(); + + $adapter->write( + 'test/text.txt', + 'contents', + new Config() + ); + + $this->assertTrue($adapter->fileExists('test/text.txt')); + + $this->expectException(UnableToDeleteFile::class); + $adapter->delete('test/'); + + $this->assertTrue($adapter->fileExists('test/text.txt')); + }); + } + + /** + * @test + */ + public function cannot_delete_with_empty_path(): void + { + $this->runScenario(function () { + $adapter = $this->adapter(); + + $adapter->write( + 'test/text.txt', + 'contents', + new Config() + ); + + $this->assertTrue($adapter->fileExists('test/text.txt')); + + $this->expectException(UnableToDeleteFile::class); + $adapter->delete(''); + + $this->assertTrue($adapter->fileExists('test/text.txt')); + }); + } }