function FileFieldTestBase::assertFileEntryNotExists

Asserts that a file does not exist in the database.

Parameters

\Drupal\file\FileInterface $file: The file to be validated.

string|null $message: (optional) A message to display with the assertion.

1 call to FileFieldTestBase::assertFileEntryNotExists()
FileFieldRevisionTest::testRevisions in core/modules/file/tests/src/Functional/FileFieldRevisionTest.php
Tests creating multiple revisions of a node and managing attached files.

File

core/modules/file/tests/src/Functional/FileFieldTestBase.php, line 236

Class

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

Namespace

Drupal\Tests\file\Functional

Code

public function assertFileEntryNotExists(FileInterface $file, ?string $message = NULL) : void {
  $this->container
    ->get('entity_type.manager')
    ->getStorage('file')
    ->resetCache();
  $message = $message ?? sprintf('File %s exists in database at the correct path.', $file->getFileUri());
  $this->assertNull(File::load($file->id()), $message);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.