You are here

public function LoadTest::testUuidValues in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testUuidValues()

Loads a single file and ensure that the correct values are returned.

File

core/modules/file/tests/src/Kernel/LoadTest.php, line 87

Class

LoadTest
Tests \Drupal\file\Entity\File::load().

Namespace

Drupal\Tests\file\Kernel

Code

public function testUuidValues() {

  // Create a new file entity from scratch so we know the values.
  $file = $this
    ->createFile('druplicon.txt', NULL, 'public');
  $file
    ->save();
  file_test_reset();
  $by_uuid_file = \Drupal::service('entity.repository')
    ->loadEntityByUuid('file', $file
    ->uuid());
  $this
    ->assertFileHookCalled('load');
  $this
    ->assertInstanceOf(FileInterface::class, $by_uuid_file);
  $this
    ->assertEqual($by_uuid_file
    ->id(), $file
    ->id(), 'Loading by UUID got the same fid.', 'File');
  $this
    ->assertTrue($by_uuid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.');
}