function RemoteStreamWrapperTestCase::testFileCrud in Remote Stream Wrapper 7
Same name and namespace in other branches
- 8 remote_stream_wrapper.test \RemoteStreamWrapperTestCase::testFileCrud()
Test file CRUD functions with remote files.
File
- ./
remote_stream_wrapper.test, line 81
Class
- RemoteStreamWrapperTestCase
- Tests for the remote_stream_wrapper module.
Code
function testFileCrud() {
$files = $this
->drupalGetTestFiles('image');
$file = remote_stream_wrapper_file_load_by_uri($files[0]->uri);
$this
->assertFalse($file, 'Remote file not yet saved as a managed file.');
$file = remote_stream_wrapper_file_create_by_uri($files[0]->uri);
file_save($file);
$this
->assertTrue(!empty($file->fid), 'Remote file saved successfully.');
$this
->assertEqual($file->filesize, filesize($files[0]->original_uri));
$this
->assertEqual($file->filemime, file_get_mimetype($files[0]->original_uri));
$loaded_file = remote_stream_wrapper_file_load_by_uri($files[0]->uri);
$this
->assertEqual($loaded_file->fid, $file->fid, 'Remote file managed record loaded by URI.');
// Delete the managed file record.
$result = file_delete($file);
$this
->assertIdentical($result, TRUE, 'Remote file record deleted successfully.');
$this
->assertFalse(remote_stream_wrapper_file_load_by_uri($files[0]->uri), 'Remote file managed record no longer exists.');
}