function LoadTest::testUuidValues

Same name and namespace 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. 10 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 <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityBase.php/function/EntityBase%3A%3Aload/11.x" title="Loads an entity." class="local">\Drupal\file\Entity\File::load</a>().

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.