diff --git a/modules/image/image.test b/modules/image/image.test index 3591979..d34c963 100644 --- a/modules/image/image.test +++ b/modules/image/image.test @@ -184,6 +184,30 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase { } /** + * Test that we do not pass an array to drupal_add_http_header. + */ + function testImageContentTypeHeaders() { + // Create a user to test this with. + $login_user = $this->drupalCreateUser(array('access content')); + $files = $this->drupalGetTestFiles('image'); + $file = array_shift($files); + $file->uid = $login_user->uid; + // Copy the test file to private folder. + $destination_directory = 'private://new_test_file_dir'; + file_prepare_directory($destination_directory); + $private_file = file_copy($file, $destination_directory, FILE_EXISTS_RENAME); + // Tell image_module_test module to return the headers we want to test. + variable_set('image_module_test_invalid_headers', $private_file->uri); + // Invoke image_style_deliver so it will try to set headers. + $generated_url = image_style_url($this->style_name, $private_file->uri); + // Make sure we are logged in. + $this->drupalLogin($login_user); + // Visit the URL for the generated image style. + $this->drupalGet($generated_url); + variable_del('image_module_test_invalid_headers'); + } + + /** * Test image_style_url(). */ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FALSE) { diff --git a/modules/image/tests/image_module_test.module b/modules/image/tests/image_module_test.module index 8a322fb..fc66d9b 100644 --- a/modules/image/tests/image_module_test.module +++ b/modules/image/tests/image_module_test.module @@ -9,6 +9,9 @@ function image_module_test_file_download($uri) { if (variable_get('image_module_test_file_download', FALSE) == $uri) { return array('X-Image-Owned-By' => 'image_module_test'); } + if (variable_get('image_module_test_invalid_headers', FALSE) == $uri) { + return array('Content-Type' => 'image/png'); + } } /**