Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / File / UnmanagedDeleteTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\File;
4
5 /**
6  * Tests the unmanaged file delete function.
7  *
8  * @group File
9  */
10 class UnmanagedDeleteTest extends FileTestBase {
11   /**
12    * Delete a normal file.
13    */
14   public function testNormal() {
15     // Create a file for testing
16     $uri = $this->createUri();
17
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.');
21   }
22
23   /**
24    * Try deleting a missing file.
25    */
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.');
29   }
30
31   /**
32    * Try deleting a directory.
33    */
34   public function testDirectory() {
35     // A directory to operate on.
36     $directory = $this->createDirectory();
37
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.');
41   }
42
43 }