function RemoteStreamWrapperTestCase::testRemoteImageStyles in Remote Stream Wrapper 7
Same name and namespace in other branches
- 8 remote_stream_wrapper.test \RemoteStreamWrapperTestCase::testRemoteImageStyles()
Test that remote images can be used with image styles.
File
- ./
remote_stream_wrapper.test, line 104
Class
- RemoteStreamWrapperTestCase
- Tests for the remote_stream_wrapper module.
Code
function testRemoteImageStyles() {
$files = $this
->drupalGetTestFiles('image');
$file = remote_stream_wrapper_file_create_by_uri($files[0]->uri);
file_save($file);
$generated_uri = remote_stream_wrapper_image_style_path('thumbnail', $file->uri);
$output = theme('image_style', array(
'style_name' => 'thumbnail',
'path' => $file->uri,
));
$this
->drupalSetContent($output);
$elements = $this
->xpath('//img');
$this
->drupalGet($elements[0]['src']);
$this
->assertResponse(200);
$this
->assertTrue(is_file($generated_uri), t('Generated file does exist after we accessed it.'));
$this
->assertRaw(file_get_contents($generated_uri), t('URL returns expected file.'));
$generated_image_info = image_get_info($generated_uri);
$this
->assertEqual($this
->drupalGetHeader('Content-Type'), $generated_image_info['mime_type'], t('Expected Content-Type was reported.'));
$this
->assertEqual($this
->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], t('Expected Content-Length was reported.'));
}