function FileLoadTest::testSingleValues
Load a single file and ensure that the correct values are returned.
File
-
modules/
simpletest/ tests/ file.test, line 2140
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), 'file_load() returned an object.');
$this->assertEqual($by_fid_file->fid, $file->fid, 'Loading by fid got the same fid.', 'File');
$this->assertEqual($by_fid_file->uri, $file->uri, 'Loading by fid got the correct filepath.', 'File');
$this->assertEqual($by_fid_file->filename, $file->filename, 'Loading by fid got the correct filename.', 'File');
$this->assertEqual($by_fid_file->filemime, $file->filemime, 'Loading by fid got the correct MIME type.', 'File');
$this->assertEqual($by_fid_file->status, $file->status, '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.