You are here

public function FileManagedUnitTestBase::assertSameFile in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php \Drupal\Tests\file\Kernel\FileManagedUnitTestBase::assertSameFile()
  2. 9 core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php \Drupal\Tests\file\Kernel\FileManagedUnitTestBase::assertSameFile()

Asserts that two files are the same by comparing the fid and filepath.

Parameters

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

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

File

core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php, line 141

Class

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

Namespace

Drupal\Tests\file\Kernel

Code

public function assertSameFile(FileInterface $file1, FileInterface $file2) {
  $this
    ->assertEquals($file1
    ->id(), $file2
    ->id(), 'Files have the same ids');
  $this
    ->assertEquals($file1
    ->getFileUri(), $file2
    ->getFileUri(), 'Files have the same path');
}