function FileDeleteTest::testDirectory

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

Try deleting a directory.

File

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

Class

FileDeleteTest
Tests the unmanaged file delete function.

Namespace

Drupal\KernelTests\Core\File

Code

public function testDirectory() {
    // A directory to operate on.
    $directory = $this->createDirectory();
    // Try to delete a directory.
    try {
        \Drupal::service('file_system')->delete($directory);
        $this->fail('Expected NotRegularFileException');
    } catch (NotRegularFileException $e) {
        // Ignore.
    }
    $this->assertDirectoryExists($directory);
}

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