You are here

function UnmanagedDeleteRecursiveTest::testSingleFile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/File/UnmanagedDeleteRecursiveTest.php \Drupal\system\Tests\File\UnmanagedDeleteRecursiveTest::testSingleFile()

Delete a normal file.

File

core/modules/system/src/Tests/File/UnmanagedDeleteRecursiveTest.php, line 19
Contains \Drupal\system\Tests\File\UnmanagedDeleteRecursiveTest.

Class

UnmanagedDeleteRecursiveTest
Tests the unmanaged file delete recursive function.

Namespace

Drupal\system\Tests\File

Code

function testSingleFile() {

  // Create a file for testing
  $filepath = file_default_scheme() . '://' . $this
    ->randomMachineName();
  file_put_contents($filepath, '');

  // Delete the file.
  $this
    ->assertTrue(file_unmanaged_delete_recursive($filepath), 'Function reported success.');
  $this
    ->assertFalse(file_exists($filepath), 'Test file has been deleted.');
}