You are here

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

Asserts that two files have the same values (except timestamp).

Parameters

\Drupal\file\FileInterface $before: File object to compare.

\Drupal\file\FileInterface $after: File object to compare.

14 calls to FileManagedUnitTestBase::assertFileUnchanged()
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 112
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 assertFileUnchanged(FileInterface $before, FileInterface $after) {
  $this
    ->assertEqual($before
    ->id(), $after
    ->id(), t('File id is the same: %file1 == %file2.', array(
    '%file1' => $before
      ->id(),
    '%file2' => $after
      ->id(),
  )), 'File unchanged');
  $this
    ->assertEqual($before
    ->getOwner()
    ->id(), $after
    ->getOwner()
    ->id(), t('File owner is the same: %file1 == %file2.', array(
    '%file1' => $before
      ->getOwner()
      ->id(),
    '%file2' => $after
      ->getOwner()
      ->id(),
  )), 'File unchanged');
  $this
    ->assertEqual($before
    ->getFilename(), $after
    ->getFilename(), t('File name is the same: %file1 == %file2.', array(
    '%file1' => $before
      ->getFilename(),
    '%file2' => $after
      ->getFilename(),
  )), 'File unchanged');
  $this
    ->assertEqual($before
    ->getFileUri(), $after
    ->getFileUri(), t('File path is the same: %file1 == %file2.', array(
    '%file1' => $before
      ->getFileUri(),
    '%file2' => $after
      ->getFileUri(),
  )), 'File unchanged');
  $this
    ->assertEqual($before
    ->getMimeType(), $after
    ->getMimeType(), t('File MIME type is the same: %file1 == %file2.', array(
    '%file1' => $before
      ->getMimeType(),
    '%file2' => $after
      ->getMimeType(),
  )), 'File unchanged');
  $this
    ->assertEqual($before
    ->getSize(), $after
    ->getSize(), t('File size is the same: %file1 == %file2.', array(
    '%file1' => $before
      ->getSize(),
    '%file2' => $after
      ->getSize(),
  )), 'File unchanged');
  $this
    ->assertEqual($before
    ->isPermanent(), $after
    ->isPermanent(), t('File status is the same: %file1 == %file2.', array(
    '%file1' => $before
      ->isPermanent(),
    '%file2' => $after
      ->isPermanent(),
  )), 'File unchanged');
}