You are here

function DeleteTest::testUnused in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/file/src/Tests/DeleteTest.php \Drupal\file\Tests\DeleteTest::testUnused()

Tries deleting a normal file (as opposed to a directory, symlink, etc).

File

core/modules/file/src/Tests/DeleteTest.php, line 21
Contains \Drupal\file\Tests\DeleteTest.

Class

DeleteTest
Tests the file delete function.

Namespace

Drupal\file\Tests

Code

function testUnused() {
  $file = $this
    ->createFile();

  // Check that deletion removes the file and database record.
  $this
    ->assertTrue(is_file($file
    ->getFileUri()), 'File exists.');
  $file
    ->delete();
  $this
    ->assertFileHooksCalled(array(
    'delete',
  ));
  $this
    ->assertFalse(file_exists($file
    ->getFileUri()), 'Test file has actually been deleted.');
  $this
    ->assertFalse(File::load($file
    ->id()), 'File was removed from the database.');
}