function FileFieldTestBaseTrait::assertFileNotExists

Asserts that a file does not exist on disk.

Overrides PHPUnit\Framework\Assert::assertFileNotExists() to also work with file entities.

Parameters

\Drupal\File\FileInterface|string $file: Either the file entity or the file URI.

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

See also

https://www.drupal.org/node/3057326

File

core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit6/FileFieldTestBaseTrait.php, line 48

Class

FileFieldTestBaseTrait
Makes Drupal's test API forward compatible with multiple versions of PHPUnit.

Namespace

Drupal\TestTools\PhpUnitCompatibility\PhpUnit6

Code

public static function assertFileNotExists($file, $message = NULL) {
    if ($file instanceof FileInterface) {
        @trigger_error('Passing a File entity as $file argument to FileFieldTestBase::assertFileNotExists is deprecated in drupal:8.8.0. It will be removed from drupal:9.0.0. Instead, pass the File entity URI via File::getFileUri(). See https://www.drupal.org/node/3057326', E_USER_DEPRECATED);
        $file = $file->getFileUri();
    }
    $message = isset($message) ? $message : new FormattableMarkup('File %file exists on the disk.', [
        '%file' => $file,
    ]);
    parent::assertFileNotExists($file, $message);
}

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