You are here

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

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

2 calls to FileManagedUnitTestBase::assertSameFile()
MoveTest::testExistingReplace in core/modules/file/src/Tests/MoveTest.php
Test replacement when moving onto a file that already exists.
SaveDataTest::testExistingReplace in core/modules/file/src/Tests/SaveDataTest.php
Test file_save_data() when replacing an existing file.

File

core/modules/file/src/Tests/FileManagedUnitTestBase.php, line 143
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 assertSameFile(FileInterface $file1, FileInterface $file2) {
  $this
    ->assertEqual($file1
    ->id(), $file2
    ->id(), t('Files have the same ids: %file1 == %file2.', array(
    '%file1' => $file1
      ->id(),
    '%file2-fid' => $file2
      ->id(),
  )), 'Same file');
  $this
    ->assertEqual($file1
    ->getFileUri(), $file2
    ->getFileUri(), t('Files have the same path: %file1 == %file2.', array(
    '%file1' => $file1
      ->getFileUri(),
    '%file2' => $file2
      ->getFileUri(),
  )), 'Same file');
}