You are here

function FileTestCase::assertSameFile in Drupal 7

Check that two files are the same by comparing the fid and filepath.

Parameters

$file1: File object to compare.

$file2: File object to compare.

2 calls to FileTestCase::assertSameFile()
FileMoveTest::testExistingReplace in modules/simpletest/tests/file.test
Test replacement when moving onto a file that already exists.
FileSaveDataTest::testExistingReplace in modules/simpletest/tests/file.test
Test file_save_data() when replacing an existing file.

File

modules/simpletest/tests/file.test, line 90
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileTestCase
Base class for file tests that adds some additional file specific assertions and helper functions.

Code

function assertSameFile($file1, $file2) {
  $this
    ->assertEqual($file1->fid, $file2->fid, format_string('Files have the same ids: %file1 == %file2.', array(
    '%file1' => $file1->fid,
    '%file2-fid' => $file2->fid,
  )), 'Same file');
  $this
    ->assertEqual($file1->uri, $file2->uri, format_string('Files have the same path: %file1 == %file2.', array(
    '%file1' => $file1->uri,
    '%file2' => $file2->uri,
  )), 'Same file');
}