function FileSystemTest::testDestinationDirectoryFailureOnCopy
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testDestinationDirectoryFailureOnCopy()
- 10 core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testDestinationDirectoryFailureOnCopy()
- 11.x core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php \Drupal\KernelTests\Core\File\FileSystemTest::testDestinationDirectoryFailureOnCopy()
@covers ::copy
File
-
core/
tests/ Drupal/ KernelTests/ Core/ File/ FileSystemTest.php, line 53
Class
- FileSystemTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21File%21FileSystem.php/class/FileSystem/8.9.x" title="Provides helpers to operate on files and stream wrappers." class="local">\Drupal\Core\File\FileSystem</a> @group File
Namespace
Drupal\KernelTests\Core\FileCode
public function testDestinationDirectoryFailureOnCopy() {
$this->expectException(DirectoryNotReadyException::class);
$this->expectExceptionMessage("The specified file 'public://test.txt' could not be copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions");
touch('public://test.txt');
// public://subdirectory has not been created, so \Drupal::service('file_system')->prepareDirectory()
// will fail, causing copy() to throw DirectoryNotReadyException.
$this->fileSystem
->copy('public://test.txt', 'public://subdirectory/test.txt');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.