You are here

function FileUnmanagedDeleteRecursiveTest::testSubDirectory in SimpleTest 7

Try deleting subdirectories with some files.

File

tests/file.test, line 1042
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileUnmanagedDeleteRecursiveTest
Deletion related tests.

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), t('Function reported success.'));
  $this
    ->assertFalse(file_exists($filepathA), t('Test file A has been deleted.'));
  $this
    ->assertFalse(file_exists($filepathB), t('Test file B has been deleted.'));
  $this
    ->assertFalse(file_exists($subdirectory), t('Subdirectory has been deleted.'));
  $this
    ->assertFalse(file_exists($directory), t('Directory has been deleted.'));
}