function DeleteTest::testUnused
Same name in other branches
- 8.9.x core/modules/file/tests/src/Kernel/DeleteTest.php \Drupal\Tests\file\Kernel\DeleteTest::testUnused()
- 10 core/modules/file/tests/src/Kernel/DeleteTest.php \Drupal\Tests\file\Kernel\DeleteTest::testUnused()
- 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\KernelCode
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->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.