function FileDeleteTest::testSymlinkDirectory

Tests deleting a symlink to a directory.

File

core/tests/Drupal/KernelTests/Core/File/FileDeleteTest.php, line 57

Class

FileDeleteTest
Tests the unmanaged file delete function.

Namespace

Drupal\KernelTests\Core\File

Code

public function testSymlinkDirectory() : void {
    // A directory to operate on.
    $directory = \Drupal::service('file_system')->realpath($this->createDirectory());
    $link = dirname($directory) . '/' . $this->randomMachineName();
    symlink($directory, $link);
    $this->assertDirectoryExists($link);
    \Drupal::service('file_system')->delete($link);
    $this->assertDirectoryExists($directory);
    $this->assertDirectoryDoesNotExist($link);
}

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