function FileManagedUnitTestBase::assertDifferentFile

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php \Drupal\Tests\file\Kernel\FileManagedUnitTestBase::assertDifferentFile()
  2. 10 core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php \Drupal\Tests\file\Kernel\FileManagedUnitTestBase::assertDifferentFile()
  3. 11.x 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
Test that copying over an existing file fails when instructed to do so.
CopyTest::testExistingRename in core/modules/file/tests/src/Kernel/CopyTest.php
Test renaming when copying over a file that already exists.
CopyTest::testExistingReplace in core/modules/file/tests/src/Kernel/CopyTest.php
Test replacement when copying over a file that already exists.
CopyTest::testNormal in core/modules/file/tests/src/Kernel/CopyTest.php
Test file copying in the normal, base case.
MoveTest::testExistingError in core/modules/file/tests/src/Kernel/MoveTest.php
Test 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->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', [
        '%file1' => $file1->id(),
        '%file2' => $file2->id(),
    ]), 'Different file');
    $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', [
        '%file1' => $file1->getFileUri(),
        '%file2' => $file2->getFileUri(),
    ]), 'Different file');
}

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