3 namespace Drupal\KernelTests\Core\File;
6 * Tests the unmanaged file delete function.
10 class UnmanagedDeleteTest extends FileTestBase {
12 * Delete a normal file.
14 public function testNormal() {
15 // Create a file for testing
16 $uri = $this->createUri();
18 // Delete a regular file
19 $this->assertTrue(file_unmanaged_delete($uri), 'Deleted worked.');
20 $this->assertFalse(file_exists($uri), 'Test file has actually been deleted.');
24 * Try deleting a missing file.
26 public function testMissing() {
27 // Try to delete a non-existing file
28 $this->assertTrue(file_unmanaged_delete(file_default_scheme() . '/' . $this->randomMachineName()), 'Returns true when deleting a non-existent file.');
32 * Try deleting a directory.
34 public function testDirectory() {
35 // A directory to operate on.
36 $directory = $this->createDirectory();
38 // Try to delete a directory
39 $this->assertFalse(file_unmanaged_delete($directory), 'Could not delete the delete directory.');
40 $this->assertTrue(file_exists($directory), 'Directory has not been deleted.');