public function FileManagedTestBase::assertSameFile in Drupal 8
Same name in this branch
- 8 core/modules/file/src/Tests/FileManagedTestBase.php \Drupal\file\Tests\FileManagedTestBase::assertSameFile()
- 8 core/modules/file/tests/src/Functional/FileManagedTestBase.php \Drupal\Tests\file\Functional\FileManagedTestBase::assertSameFile()
Same name and namespace in other branches
- 9 core/modules/file/tests/src/Functional/FileManagedTestBase.php \Drupal\Tests\file\Functional\FileManagedTestBase::assertSameFile()
- 10 core/modules/file/tests/src/Functional/FileManagedTestBase.php \Drupal\Tests\file\Functional\FileManagedTestBase::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.
File
- core/
modules/ file/ tests/ src/ Functional/ FileManagedTestBase.php, line 128
Class
- FileManagedTestBase
- Base class for file tests that use the file_test module to test uploads and hooks.
Namespace
Drupal\Tests\file\FunctionalCode
public function assertSameFile(FileInterface $file1, FileInterface $file2) {
$this
->assertEqual($file1
->id(), $file2
->id(), t('Files have the same ids: %file1 == %file2.', [
'%file1' => $file1
->id(),
'%file2-fid' => $file2
->id(),
]), 'Same file');
$this
->assertEqual($file1
->getFileUri(), $file2
->getFileUri(), t('Files have the same path: %file1 == %file2.', [
'%file1' => $file1
->getFileUri(),
'%file2' => $file2
->getFileUri(),
]), 'Same file');
}