function LoadTest::testSingleValues

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testSingleValues()
  2. 10 core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testSingleValues()
  3. 11.x core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testSingleValues()

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

File

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

Class

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

Namespace

Drupal\Tests\file\Kernel

Code

public function testSingleValues() {
    // Create a new file entity from scratch so we know the values.
    $file = $this->createFile('druplicon.txt', NULL, 'public');
    $by_fid_file = File::load($file->id());
    $this->assertFileHookCalled('load');
    $this->assertIsObject($by_fid_file);
    $this->assertEqual($by_fid_file->id(), $file->id(), 'Loading by fid got the same fid.', 'File');
    $this->assertEqual($by_fid_file->getFileUri(), $file->getFileUri(), 'Loading by fid got the correct filepath.', 'File');
    $this->assertEqual($by_fid_file->getFilename(), $file->getFilename(), 'Loading by fid got the correct filename.', 'File');
    $this->assertEqual($by_fid_file->getMimeType(), $file->getMimeType(), 'Loading by fid got the correct MIME type.', 'File');
    $this->assertEqual($by_fid_file->isPermanent(), $file->isPermanent(), 'Loading by fid got the correct status.', 'File');
    $this->assertTrue($by_fid_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.