You are here

public function LoadTest::testUuidValues in Zircon Profile 8

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

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

File

core/modules/file/src/Tests/LoadTest.php, line 90
Contains \Drupal\file\Tests\LoadTest.

Class

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

Namespace

Drupal\file\Tests

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::entityManager()
    ->loadEntityByUuid('file', $file
    ->uuid());
  $this
    ->assertFileHookCalled('load');
  $this
    ->assertTrue(is_object($by_uuid_file), '\\Drupal::entityManager()->loadEntityByUuid() returned a file object.');
  if (is_object($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.');
  }
}