function LoadTest::testSingleValues

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

File

drupal/core/modules/file/lib/Drupal/file/Tests/LoadTest.php, line 51
Definition of Drupal\file\Tests\LoadTest.

Class

LoadTest
Tests the file_load() function.

Namespace

Drupal\file\Tests

Code

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->fid);
  $this
    ->assertFileHookCalled('load');
  $this
    ->assertTrue(is_object($by_fid_file), t('file_load() returned an object.'));
  $this
    ->assertEqual($by_fid_file->fid, $file->fid, t("Loading by fid got the same fid."), 'File');
  $this
    ->assertEqual($by_fid_file->uri, $file->uri, t("Loading by fid got the correct filepath."), 'File');
  $this
    ->assertEqual($by_fid_file->filename, $file->filename, t("Loading by fid got the correct filename."), 'File');
  $this
    ->assertEqual($by_fid_file->filemime, $file->filemime, t("Loading by fid got the correct MIME type."), 'File');
  $this
    ->assertEqual($by_fid_file->status, $file->status, t("Loading by fid got the correct status."), 'File');
  $this
    ->assertTrue($by_fid_file->file_test['loaded'], t('file_test_file_load() was able to modify the file during load.'));
}