function FileDeleteTest::testSymlinkDirectoryStreamWrappers
Tests deleting using a symlinked directory using stream wrappers.
Note that this does not work because the path will be resolved to the real path in the stream wrapper and not the link.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ File/ FileDeleteTest.php, line 75
Class
- FileDeleteTest
- Tests the unmanaged file delete function.
Namespace
Drupal\KernelTests\Core\FileCode
public function testSymlinkDirectoryStreamWrappers() : void {
// A directory to operate on.
$directory = $this->createDirectory();
$link = 'public://' . $this->randomMachineName();
symlink(\Drupal::service('file_system')->realpath($directory), \Drupal::service('file_system')->realpath($link));
$this->assertDirectoryExists($link);
$this->expectExceptionMessage("Cannot delete '{$link}' because it is a directory. Use deleteRecursive() instead.");
$this->expectException(NotRegularFileException::class);
\Drupal::service('file_system')->delete($link);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.