You are here

function FileManagedUnitTestBase::assertDifferentFile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/src/Tests/FileManagedUnitTestBase.php \Drupal\file\Tests\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/src/Tests/CopyTest.php
Test that copying over an existing file fails when FILE_EXISTS_ERROR is specified.
CopyTest::testExistingRename in core/modules/file/src/Tests/CopyTest.php
Test renaming when copying over a file that already exists.
CopyTest::testExistingReplace in core/modules/file/src/Tests/CopyTest.php
Test replacement when copying over a file that already exists.
CopyTest::testNormal in core/modules/file/src/Tests/CopyTest.php
Test file copying in the normal, base case.
MoveTest::testExistingError in core/modules/file/src/Tests/MoveTest.php
Test that moving onto an existing file fails when FILE_EXISTS_ERROR is specified.

... See full list

File

core/modules/file/src/Tests/FileManagedUnitTestBase.php, line 130
Contains \Drupal\file\Tests\FileManagedUnitTestBase.

Class

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

Namespace

Drupal\file\Tests

Code

function assertDifferentFile(FileInterface $file1, FileInterface $file2) {
  $this
    ->assertNotEqual($file1
    ->id(), $file2
    ->id(), t('Files have different ids: %file1 != %file2.', array(
    '%file1' => $file1
      ->id(),
    '%file2' => $file2
      ->id(),
  )), 'Different file');
  $this
    ->assertNotEqual($file1
    ->getFileUri(), $file2
    ->getFileUri(), t('Files have different paths: %file1 != %file2.', array(
    '%file1' => $file1
      ->getFileUri(),
    '%file2' => $file2
      ->getFileUri(),
  )), 'Different file');
}