You are here

public function FileFieldTestBase::assertFileEntryExists in Drupal 8

Same name in this branch
  1. 8 core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::assertFileEntryExists()
  2. 8 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::assertFileEntryExists()
Same name and namespace in other branches
  1. 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::assertFileEntryExists()
  2. 10 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 226

Class

FileFieldTestBase
Provides methods specifically for testing File module's field handling.

Namespace

Drupal\Tests\file\Functional

Code

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);
}