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. 8.9.x core/modules/file/tests/src/Kernel/DeleteTest.php \Drupal\Tests\file\Kernel\DeleteTest::testUnused()
  3. 10 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 20

Class

DeleteTest
Tests the file delete function.

Namespace

Drupal\Tests\file\Kernel

Code

public function testUnused() : void {
    $file = $this->createFile();
    // Check that deletion removes the file and database record.
    $this->assertFileExists($file->getFileUri());
    $file->delete();
    $this->assertFileHooksCalled([
        'delete',
    ]);
    $this->assertFileDoesNotExist($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.