You are here

public function FileDeleteTest::testDirectory in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/File/FileDeleteTest.php \Drupal\KernelTests\Core\File\FileDeleteTest::testDirectory()
  2. 9 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);
}