You are here

function FileManagedTestBase::assertDifferentFile in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/file/src/Tests/FileManagedTestBase.php \Drupal\file\Tests\FileManagedTestBase::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.

File

core/modules/file/src/Tests/FileManagedTestBase.php, line 118
Contains \Drupal\file\Tests\FileManagedTestBase.

Class

FileManagedTestBase
Base class for file 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');
}