function FileManagedTestBase::assertFileUnchanged

Same name in other branches
  1. 9 core/modules/file/tests/src/Functional/FileManagedTestBase.php \Drupal\Tests\file\Functional\FileManagedTestBase::assertFileUnchanged()
  2. 8.9.x core/modules/file/src/Tests/FileManagedTestBase.php \Drupal\file\Tests\FileManagedTestBase::assertFileUnchanged()
  3. 8.9.x core/modules/file/tests/src/Functional/FileManagedTestBase.php \Drupal\Tests\file\Functional\FileManagedTestBase::assertFileUnchanged()
  4. 11.x core/modules/file/tests/src/Functional/FileManagedTestBase.php \Drupal\Tests\file\Functional\FileManagedTestBase::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.

File

core/modules/file/tests/src/Functional/FileManagedTestBase.php, line 98

Class

FileManagedTestBase
Provides a base class for testing files with the file_test module.

Namespace

Drupal\Tests\file\Functional

Code

public function assertFileUnchanged(FileInterface $before, FileInterface $after) {
    $this->assertEquals($before->id(), $after->id());
    $this->assertEquals($before->getOwner()
        ->id(), $after->getOwner()
        ->id());
    $this->assertEquals($before->getFilename(), $after->getFilename());
    $this->assertEquals($before->getFileUri(), $after->getFileUri());
    $this->assertEquals($before->getMimeType(), $after->getMimeType());
    $this->assertEquals($before->getSize(), $after->getSize());
    $this->assertEquals($before->isPermanent(), $after->isPermanent());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.