You are here

public function FileManagedTestBase::assertFileUnchanged in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Functional/FileManagedTestBase.php \Drupal\Tests\file\Functional\FileManagedTestBase::assertFileUnchanged()

Asserts that two files have the same values (except timestamp).

Parameters

\Drupal\file\FileInterface $before: File object to compare.

\Drupal\file\FileInterface $after: File object to compare.

File

core/modules/file/tests/src/Functional/FileManagedTestBase.php, line 97

Class

FileManagedTestBase
Base class for file tests that use the file_test module to test uploads and hooks.

Namespace

Drupal\Tests\file\Functional

Code

public function assertFileUnchanged(FileInterface $before, FileInterface $after) {
  $this
    ->assertEquals($before
    ->id(), $after
    ->id());
  $this
    ->assertEquals($before
    ->getOwner()
    ->id(), $after
    ->getOwner()
    ->id());
  $this
    ->assertEquals($before
    ->getFilename(), $after
    ->getFilename());
  $this
    ->assertEquals($before
    ->getFileUri(), $after
    ->getFileUri());
  $this
    ->assertEquals($before
    ->getMimeType(), $after
    ->getMimeType());
  $this
    ->assertEquals($before
    ->getSize(), $after
    ->getSize());
  $this
    ->assertEquals($before
    ->isPermanent(), $after
    ->isPermanent());
}