function FileManagedUnitTestBase::assertSameFile

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

4 calls to FileManagedUnitTestBase::assertSameFile()
FileRepositoryTest::testExistingReplace in core/modules/file/tests/src/Kernel/FileRepositoryTest.php
Tests writeData() when replacing an existing file.
FileRepositoryTest::testLoadByUri in core/modules/file/tests/src/Kernel/FileRepositoryTest.php
Tests loading a file by URI.
FileRepositoryTest::testLoadByUriCaseSensitive in core/modules/file/tests/src/Kernel/FileRepositoryTest.php
Tests loading a file by case-sensitive URI.
MoveTest::testExistingReplace in core/modules/file/tests/src/Kernel/MoveTest.php
Tests replacement when moving onto a file that already exists.

File

core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php, line 142

Class

FileManagedUnitTestBase
Provides a base class for testing file uploads and hook invocations.

Namespace

Drupal\Tests\file\Kernel

Code

public function assertSameFile(FileInterface $file1, FileInterface $file2) {
    $this->assertEquals($file1->id(), $file2->id(), 'Files have the same ids');
    $this->assertEquals($file1->getFileUri(), $file2->getFileUri(), 'Files have the same path');
}

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