function FileSystemTest::testEnsureFileExistsBeforeCopy

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testEnsureFileExistsBeforeCopy()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testEnsureFileExistsBeforeCopy()
  3. 10 core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testEnsureFileExistsBeforeCopy()

@covers ::copy

File

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

Class

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

Namespace

Drupal\KernelTests\Core\File

Code

public function testEnsureFileExistsBeforeCopy() : void {
    // We need to compute the exception message here because it will include
    // the 'real' path to the file, which varies with $this->siteDirectory.
    $this->expectException(FileNotExistsException::class);
    $this->expectExceptionMessage("File 'public://test.txt' ('{$this->siteDirectory}/files/test.txt') could not be copied because it does not exist");
    $this->fileSystem
        ->copy('public://test.txt', 'public://test-copy.txt');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.