public function DeleteTest::testUnused in Drupal 9
Same name and namespace in other branches
- 8 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()
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.');
}