// Check that the changes were actually saved to the database.
$loaded_file=file_load($file->fid,TRUE);
$loaded_file=file_load($file->fid);
$this->assertTrue($loaded_file,t("File can be loaded from the database."));
$this->assertEqual($file->filename,$loaded_file->filename,t("File name was updated correctly in the database."));
$this->assertEqual($file->filepath,$loaded_file->filepath,t("File path was updated correctly in the database."));
...
...
@@ -884,7 +900,7 @@ class FileLoadTest extends FileHookTestCase {
* Try to load a non-existent file by filepath.
*/
functiontestLoadMissingFilepath(){
$this->assertFalse(file_load(array('filepath'=>'misc/druplicon.png')),t("Try to load a file that doesn't exist in the database fails."));
$this->assertFalse(reset(file_load_multiple(array(),array('filepath'=>'misc/druplicon.png'))),t("Try to load a file that doesn't exist in the database fails."));
$this->assertFileHookCalled('load',0);
}
...
...
@@ -892,14 +908,40 @@ class FileLoadTest extends FileHookTestCase {
* Try to load a non-existent file by status.
*/
functiontestLoadInvalidStatus(){
$this->assertFalse(file_load(array('status'=>-99)),t("Trying to load a file with an invalid status fails."));
$this->assertFalse(reset(file_load_multiple(array(),array('status'=>-99))),t("Trying to load a file with an invalid status fails."));
$this->assertFileHookCalled('load',0);
}
/**
* This will test lading file data from the database.
* Load a single file and ensure that the correct values are returned.
*/
functiontestFileLoad(){
functiontestSingleValues(){
// Create a new file object from scratch so we know the values.
$file=array(
'uid'=>1,
'filename'=>'druplicon.png',
'filepath'=>'misc/druplicon.png',
'filemime'=>'image/png',
'timestamp'=>1,
'status'=>FILE_STATUS_PERMANENT,
);
$file=file_save($file);
$by_fid_file=file_load($file->fid);
$this->assertFileHookCalled('load',1);
$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->filepath,$file->filepath,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.'));
}
/**
* This will test loading file data from the database.
*/
functiontestMultiple(){
// Create a new file object.
$file=array(
'uid'=>1,
...
...
@@ -913,25 +955,24 @@ class FileLoadTest extends FileHookTestCase {