function LoadTest::testUuidValues

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

Class

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

Namespace

Drupal\Tests\file\Kernel

Code

public function testUuidValues() : void {
    // 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->assertEquals($file->id(), $by_uuid_file->id(), 'Loading by UUID got the same fid.');
    $this->assertTrue($by_uuid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.');
}

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