diff --git a/modules/image/image.test b/modules/image/image.test index 3591979..fa7b013 100644 --- a/modules/image/image.test +++ b/modules/image/image.test @@ -184,6 +184,29 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase { } /** + * Test that we do not pass an array to drupal_add_http_header. + */ + function testImageContentTypeHeaders() { + $files = $this->drupalGetTestFiles('image'); + $file = array_shift($files); + // Copy the test file to private folder. + $private_file = file_copy($file, 'private://', 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); + $this->drupalGet($generated_url); + // Check that we did not get a notice in watchdog. + $last_message = db_select('watchdog', 'w') + ->fields('w', array('variables')) + ->orderBy('wid', 'DESC') + ->execute() + ->fetchAssoc(); + $this->assertFalse(strpos($last_message['variables'], 'Array to string conversion') > 0); + 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..cf49618 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/jpg'); + } } /**