function FileUnmanagedDeleteRecursiveTest::testDirectory
7.x file.test | FileUnmanagedDeleteRecursiveTest::testDirectory() |
Try deleting a directory with some files.
File
- drupal-7.x/
modules/ simpletest/ tests/ file.test, line 1287 - This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.
Class
- FileUnmanagedDeleteRecursiveTest
- Deletion related tests.
Code
function testDirectory() {
// A directory to operate on.
$directory = $this->createDirectory();
$filepathA = $directory . '/A';
$filepathB = $directory . '/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($directory), 'Directory has been deleted.');
}