function FileFieldTestBase::assertFileEntryExists
Same name in this branch
- 8.9.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::assertFileEntryExists()
Same name in other branches
- 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::assertFileEntryExists()
- 10 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::assertFileEntryExists()
- 11.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::assertFileEntryExists()
Asserts that a file exists in the database.
File
-
core/
modules/ file/ src/ Tests/ FileFieldTestBase.php, line 280
Class
- FileFieldTestBase
- Provides methods specifically for testing File module's field handling.
Namespace
Drupal\file\TestsCode
public function assertFileEntryExists($file, $message = NULL) {
$this->container
->get('entity_type.manager')
->getStorage('file')
->resetCache();
$db_file = File::load($file->id());
$message = isset($message) ? $message : new FormattableMarkup('File %file exists in database at the correct path.', [
'%file' => $file->getFileUri(),
]);
$this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.