You are here

public function FileSystemTest::testCopyFailureIfFileAlreadyExists in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testCopyFailureIfFileAlreadyExists()
  2. 9 core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testCopyFailureIfFileAlreadyExists()

@covers ::copy

File

core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php, line 65

Class

FileSystemTest
@coversDefaultClass \Drupal\Core\File\FileSystem @group File

Namespace

Drupal\KernelTests\Core\File

Code

public function testCopyFailureIfFileAlreadyExists() {
  $this
    ->expectException(FileExistsException::class);
  $this
    ->expectExceptionMessage("File 'public://test.txt' could not be copied because a file by that name already exists in the destination directory ('')");
  $uri = 'public://test.txt';
  touch($uri);
  $this->fileSystem
    ->copy($uri, $uri, FileSystemInterface::EXISTS_ERROR);
}