function FileFieldTestBase::assertFileEntryExists
Same name in other branches
- 8.9.x core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::assertFileEntryExists()
- 8.9.x 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.
5 calls to FileFieldTestBase::assertFileEntryExists()
- FileFieldRevisionTest::testRevisions in core/
modules/ file/ tests/ src/ Functional/ FileFieldRevisionTest.php - Tests creating multiple revisions of a node and managing attached files.
- FileFieldValidateTest::testFileExtension in core/
modules/ file/ tests/ src/ Functional/ FileFieldValidateTest.php - Tests file extension checking.
- FileFieldValidateTest::testFileMaxSize in core/
modules/ file/ tests/ src/ Functional/ FileFieldValidateTest.php - Tests the max file size validator.
- FileFieldValidateTest::testFileRemoval in core/
modules/ file/ tests/ src/ Functional/ FileFieldValidateTest.php - Checks that a file can always be removed if it does not pass validation.
- FileFieldValidateTest::testRequired in core/
modules/ file/ tests/ src/ Functional/ FileFieldValidateTest.php - Tests the required property on file fields.
File
-
core/
modules/ file/ tests/ src/ Functional/ FileFieldTestBase.php, line 222
Class
- FileFieldTestBase
- Provides methods specifically for testing File module's field handling.
Namespace
Drupal\Tests\file\FunctionalCode
public function assertFileEntryExists($file, $message = NULL) {
$this->container
->get('entity_type.manager')
->getStorage('file')
->resetCache();
$db_file = File::load($file->id());
$message = $message ?? new FormattableMarkup('File %file exists in database at the correct path.', [
'%file' => $file->getFileUri(),
]);
$this->assertEquals($file->getFileUri(), $db_file->getFileUri(), $message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.