You are here

function FileFieldTestBase::assertFileEntryExists in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::assertFileEntryExists()

Asserts that a file exists in the database.

5 calls to FileFieldTestBase::assertFileEntryExists()
FileFieldRevisionTest::testRevisions in core/modules/file/src/Tests/FileFieldRevisionTest.php
Tests creating multiple revisions of a node and managing attached files.
FileFieldValidateTest::testFileExtension in core/modules/file/src/Tests/FileFieldValidateTest.php
Tests file extension checking.
FileFieldValidateTest::testFileMaxSize in core/modules/file/src/Tests/FileFieldValidateTest.php
Tests the max file size validator.
FileFieldValidateTest::testFileRemoval in core/modules/file/src/Tests/FileFieldValidateTest.php
Checks that a file can always be removed if it does not pass validation.
FileFieldValidateTest::testRequired in core/modules/file/src/Tests/FileFieldValidateTest.php
Tests the required property on file fields.

File

core/modules/file/src/Tests/FileFieldTestBase.php, line 273
Contains \Drupal\file\Tests\FileFieldTestBase.

Class

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

Namespace

Drupal\file\Tests

Code

function assertFileEntryExists($file, $message = NULL) {
  $this->container
    ->get('entity.manager')
    ->getStorage('file')
    ->resetCache();
  $db_file = File::load($file
    ->id());
  $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array(
    '%file' => $file
      ->getFileUri(),
  ));
  $this
    ->assertEqual($db_file
    ->getFileUri(), $file
    ->getFileUri(), $message);
}