diff --git a/core/lib/Drupal/Core/File/UnmanagedFileHandler.php b/core/lib/Drupal/Core/File/UnmanagedFileHandler.php index fb7eb56a55..cc77c45da9 100644 --- a/core/lib/Drupal/Core/File/UnmanagedFileHandler.php +++ b/core/lib/Drupal/Core/File/UnmanagedFileHandler.php @@ -90,7 +90,7 @@ public function delete($path) { // signal that no action was taken. if (!file_exists($path)) { $this->logger->notice('The file %path was not deleted because it does not exist.', ['%path' => $path]); - return FALSE; + return TRUE; } // We cannot handle anything other than files and directories. diff --git a/core/tests/Drupal/KernelTests/Core/File/UnmanagedCopyTest.php b/core/tests/Drupal/KernelTests/Core/File/UnmanagedCopyTest.php index da2f36f696..0352fa306e 100644 --- a/core/tests/Drupal/KernelTests/Core/File/UnmanagedCopyTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/UnmanagedCopyTest.php @@ -2,6 +2,7 @@ namespace Drupal\KernelTests\Core\File; +use Drupal\Core\File\Exception\FileNotExistsException; use Drupal\Core\Site\Settings; use Drupal\Core\File\FileSystem; @@ -49,6 +50,7 @@ public function testNonExistent() { // Copy non-existent file $desired_filepath = $this->randomMachineName(); $this->assertFalse(file_exists($desired_filepath), "Randomly named file doesn't exist."); + $this->expectException(FileNotExistsException::class); $new_filepath = \Drupal::service('file_handler.unmanaged')->copy($desired_filepath, $this->randomMachineName()); $this->assertFalse($new_filepath, 'Copying a missing file fails.'); } @@ -71,6 +73,7 @@ public function testOverwriteSelf() { $this->assertFilePermissions($new_filepath, Settings::get('file_chmod_file', FileSystem::CHMOD_FILE)); // Copy the file onto itself without renaming fails. + $this->expectException(FileNotExistsException::class); $new_filepath = $file_handler->copy($uri, $uri, FILE_EXISTS_ERROR); $this->assertFalse($new_filepath, 'Copying onto itself without renaming fails.'); $this->assertTrue(file_exists($uri), 'File exists after copying onto itself.'); diff --git a/core/tests/Drupal/KernelTests/Core/File/UnmanagedMoveTest.php b/core/tests/Drupal/KernelTests/Core/File/UnmanagedMoveTest.php index 2509278e3f..45e4d63087 100644 --- a/core/tests/Drupal/KernelTests/Core/File/UnmanagedMoveTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/UnmanagedMoveTest.php @@ -2,6 +2,7 @@ namespace Drupal\KernelTests\Core\File; +use Drupal\Core\File\Exception\FileException; use Drupal\Core\Site\Settings; use Drupal\Core\File\FileSystem; @@ -64,6 +65,7 @@ public function testOverwriteSelf() { // Move the file onto itself without renaming shouldn't make changes. /** @var \Drupal\Core\File\UnmanagedFileHandlerInterface $file_handler */ $file_handler = \Drupal::service('file_handler.unmanaged'); + $this->expectException(FileException::class); $new_filepath = $file_handler->move($uri, $uri, FILE_EXISTS_REPLACE); $this->assertFalse($new_filepath, 'Moving onto itself without renaming fails.'); $this->assertTrue(file_exists($uri), 'File exists after moving onto itself.');