You are here

public function FileManagedUnitTestBase::assertSameFile in Drupal 9

Same name and namespace in other branches
  1. 8 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.

2 calls to FileManagedUnitTestBase::assertSameFile()
MoveTest::testExistingReplace in core/modules/file/tests/src/Kernel/MoveTest.php
Tests replacement when moving onto a file that already exists.
SaveDataTest::testExistingReplace in core/modules/file/tests/src/Kernel/SaveDataTest.php
Tests file_save_data() when replacing an existing file.

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');
}