function UnmanagedDeleteRecursiveTest::testSubDirectory

Try deleting subdirectories with some files.

File

drupal/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteRecursiveTest.php, line 68
Definition of Drupal\system\Tests\File\UnmanagedDeleteRecursiveTest.

Class

UnmanagedDeleteRecursiveTest
Deletion related tests.

Namespace

Drupal\system\Tests\File

Code

function testSubDirectory() {

  // A directory to operate on.
  $directory = $this
    ->createDirectory();
  $subdirectory = $this
    ->createDirectory($directory . '/sub');
  $filepathA = $directory . '/A';
  $filepathB = $subdirectory . '/B';
  file_put_contents($filepathA, '');
  file_put_contents($filepathB, '');

  // Delete the directory.
  $this
    ->assertTrue(file_unmanaged_delete_recursive($directory), 'Function reported success.');
  $this
    ->assertFalse(file_exists($filepathA), 'Test file A has been deleted.');
  $this
    ->assertFalse(file_exists($filepathB), 'Test file B has been deleted.');
  $this
    ->assertFalse(file_exists($subdirectory), 'Subdirectory has been deleted.');
  $this
    ->assertFalse(file_exists($directory), 'Directory has been deleted.');
}