You are here

function FileTestCase::assertFileUnchanged in SimpleTest 7

Check that two files have the same values for all fields other than the timestamp.

Parameters

$before: File object to compare.

$after: File object to compare.

14 calls to FileTestCase::assertFileUnchanged()
FileCopyTest::testExistingError in tests/file.test
Test that copying over an existing file fails when FILE_EXISTS_ERROR is specified.
FileCopyTest::testExistingRename in tests/file.test
Test renaming when copying over a file that already exists.
FileCopyTest::testExistingReplace in tests/file.test
Test replacement when copying over a file that already exists.
FileCopyTest::testNormal in tests/file.test
Test file copying in the normal, base case.
FileMoveTest::testExistingError in tests/file.test
Test that moving onto an existing file fails when FILE_EXISTS_ERROR is specified.

... See full list

File

tests/file.test, line 59
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 assertFileUnchanged($before, $after) {
  $this
    ->assertEqual($before->fid, $after->fid, t('File id is the same: %file1 == %file2.', array(
    '%file1' => $before->fid,
    '%file2' => $after->fid,
  )), 'File unchanged');
  $this
    ->assertEqual($before->uid, $after->uid, t('File owner is the same: %file1 == %file2.', array(
    '%file1' => $before->uid,
    '%file2' => $after->uid,
  )), 'File unchanged');
  $this
    ->assertEqual($before->filename, $after->filename, t('File name is the same: %file1 == %file2.', array(
    '%file1' => $before->filename,
    '%file2' => $after->filename,
  )), 'File unchanged');
  $this
    ->assertEqual($before->uri, $after->uri, t('File path is the same: %file1 == %file2.', array(
    '%file1' => $before->uri,
    '%file2' => $after->uri,
  )), 'File unchanged');
  $this
    ->assertEqual($before->filemime, $after->filemime, t('File MIME type is the same: %file1 == %file2.', array(
    '%file1' => $before->filemime,
    '%file2' => $after->filemime,
  )), 'File unchanged');
  $this
    ->assertEqual($before->filesize, $after->filesize, t('File size is the same: %file1 == %file2.', array(
    '%file1' => $before->filesize,
    '%file2' => $after->filesize,
  )), 'File unchanged');
  $this
    ->assertEqual($before->status, $after->status, t('File status is the same: %file1 == %file2.', array(
    '%file1' => $before->status,
    '%file2' => $after->status,
  )), 'File unchanged');
}