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. 8.9.x 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
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.
FileRepositoryTest::testExistingRename in core/modules/file/tests/src/Kernel/FileRepositoryTest.php
Tests writeData() when renaming around an existing file.

... See full list

File

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

Class

FileManagedUnitTestBase
Provides a base class for testing file uploads and hook invocations.

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

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