You are here

public function FileDeleteRecursiveTest::testSingleFile in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/File/FileDeleteRecursiveTest.php \Drupal\KernelTests\Core\File\FileDeleteRecursiveTest::testSingleFile()
  2. 9 core/tests/Drupal/KernelTests/Core/File/FileDeleteRecursiveTest.php \Drupal\KernelTests\Core\File\FileDeleteRecursiveTest::testSingleFile()

Delete a normal file.

File

core/tests/Drupal/KernelTests/Core/File/FileDeleteRecursiveTest.php, line 15

Class

FileDeleteRecursiveTest
Tests the unmanaged file delete recursive function.

Namespace

Drupal\KernelTests\Core\File

Code

public function testSingleFile() {

  // Create a file for testing
  $filepath = 'public://' . $this
    ->randomMachineName();
  file_put_contents($filepath, '');

  // Delete the file.
  $this
    ->assertTrue(\Drupal::service('file_system')
    ->deleteRecursive($filepath), 'Function reported success.');
  $this
    ->assertFileDoesNotExist($filepath);
}