You are here

public function FileManagedUnitTestBase::assertDifferentFile 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::assertDifferentFile()

Asserts that two files are not 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.

8 calls to FileManagedUnitTestBase::assertDifferentFile()
CopyTest::testExistingError in core/modules/file/tests/src/Kernel/CopyTest.php
Tests that copying over an existing file fails when instructed to do so.
CopyTest::testExistingRename in core/modules/file/tests/src/Kernel/CopyTest.php
Tests renaming when copying over a file that already exists.
CopyTest::testExistingReplace in core/modules/file/tests/src/Kernel/CopyTest.php
Tests replacement when copying over a file that already exists.
CopyTest::testNormal in core/modules/file/tests/src/Kernel/CopyTest.php
Tests file copying in the normal, base case.
MoveTest::testExistingError in core/modules/file/tests/src/Kernel/MoveTest.php
Tests that moving onto an existing file fails when instructed to do so.

... See full list

File

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

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 assertDifferentFile(FileInterface $file1, FileInterface $file2) {
  $this
    ->assertNotEquals($file1
    ->id(), $file2
    ->id(), 'Files have different ids');
  $this
    ->assertNotEquals($file1
    ->getFileUri(), $file2
    ->getFileUri(), 'Files have different paths');
}