function DeleteTest::testUnused

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/DeleteTest.php \Drupal\Tests\file\Kernel\DeleteTest::testUnused()
  2. 10 core/modules/file/tests/src/Kernel/DeleteTest.php \Drupal\Tests\file\Kernel\DeleteTest::testUnused()
  3. 11.x core/modules/file/tests/src/Kernel/DeleteTest.php \Drupal\Tests\file\Kernel\DeleteTest::testUnused()

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

File

core/modules/file/tests/src/Kernel/DeleteTest.php, line 18

Class

DeleteTest
Tests the file delete function.

Namespace

Drupal\Tests\file\Kernel

Code

public function testUnused() {
    $file = $this->createFile();
    // Check that deletion removes the file and database record.
    $this->assertFileExists($file->getFileUri());
    $file->delete();
    $this->assertFileHooksCalled([
        'delete',
    ]);
    $this->assertFileNotExists($file->getFileUri());
    $this->assertNull(File::load($file->id()), 'File was removed from the database.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.