You are here

function FileLoadTest::testSingleValues in SimpleTest 7

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

File

tests/file.test, line 1599
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileLoadTest
Tests the file_load() function.

Code

function testSingleValues() {

  // Create a new file object 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.'));
}