Commit 0bca40b3 authored by Dries's avatar Dries

Issue #1797328 by xjm: remove t() from assertion messages in tests for the image module.

parent 7643bb2f
...@@ -170,7 +170,7 @@ function testStyle() { ...@@ -170,7 +170,7 @@ function testStyle() {
// Check that the URL was updated. // Check that the URL was updated.
$this->drupalGet($style_path); $this->drupalGet($style_path);
$this->assertResponse(200, t('Image style %original renamed to %new', array('%original' => $style['label'], '%new' => $style_name))); $this->assertResponse(200, format_string('Image style %original renamed to %new', array('%original' => $style['label'], '%new' => $style_name)));
// Check that the image was flushed after updating the style. // Check that the image was flushed after updating the style.
// This is especially important when renaming the style. Make sure that // This is especially important when renaming the style. Make sure that
...@@ -190,7 +190,7 @@ function testStyle() { ...@@ -190,7 +190,7 @@ function testStyle() {
$order_correct = FALSE; $order_correct = FALSE;
} }
} }
$this->assertTrue($order_correct, t('The order of the effects is correctly set by default.')); $this->assertTrue($order_correct, 'The order of the effects is correctly set by default.');
// Image effect deletion form. // Image effect deletion form.
...@@ -242,7 +242,7 @@ function testStyleReplacement() { ...@@ -242,7 +242,7 @@ function testStyleReplacement() {
// Test that image is displayed using newly created style. // Test that image is displayed using newly created style.
$this->drupalGet('node/' . $nid); $this->drupalGet('node/' . $nid);
$this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), t('Image displayed using style @style.', array('@style' => $style_name))); $this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
// Rename the style and make sure the image field is updated. // Rename the style and make sure the image field is updated.
$new_style_name = strtolower($this->randomName(10)); $new_style_name = strtolower($this->randomName(10));
...@@ -252,9 +252,9 @@ function testStyleReplacement() { ...@@ -252,9 +252,9 @@ function testStyleReplacement() {
'label' => $new_style_label, 'label' => $new_style_label,
); );
$this->drupalPost('admin/config/media/image-styles/edit/' . $style_name, $edit, t('Update style')); $this->drupalPost('admin/config/media/image-styles/edit/' . $style_name, $edit, t('Update style'));
$this->assertText(t('Changes to the style have been saved.'), t('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name))); $this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
$this->drupalGet('node/' . $nid); $this->drupalGet('node/' . $nid);
$this->assertRaw(image_style_url($new_style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), t('Image displayed using style replacement style.')); $this->assertRaw(image_style_url($new_style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.');
// Delete the style and choose a replacement style. // Delete the style and choose a replacement style.
$edit = array( $edit = array(
...@@ -265,7 +265,7 @@ function testStyleReplacement() { ...@@ -265,7 +265,7 @@ function testStyleReplacement() {
$this->assertRaw($message); $this->assertRaw($message);
$this->drupalGet('node/' . $nid); $this->drupalGet('node/' . $nid);
$this->assertRaw(image_style_url('thumbnail', file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), t('Image displayed using style replacement style.')); $this->assertRaw(image_style_url('thumbnail', file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.');
} }
/** /**
......
...@@ -139,13 +139,13 @@ function testImageDimensionsScale() { ...@@ -139,13 +139,13 @@ function testImageDimensionsScale() {
$return_value = image_dimensions_scale($test['input']['dimensions'], $test['input']['width'], $test['input']['height'], $test['input']['upscale']); $return_value = image_dimensions_scale($test['input']['dimensions'], $test['input']['width'], $test['input']['height'], $test['input']['upscale']);
// Check the width. // Check the width.
$this->assertEqual($test['output']['dimensions']['width'], $test['input']['dimensions']['width'], t('Computed width (@computed_width) equals expected width (@expected_width)', array('@computed_width' => $test['output']['dimensions']['width'], '@expected_width' => $test['input']['dimensions']['width']))); $this->assertEqual($test['output']['dimensions']['width'], $test['input']['dimensions']['width'], format_string('Computed width (@computed_width) equals expected width (@expected_width)', array('@computed_width' => $test['output']['dimensions']['width'], '@expected_width' => $test['input']['dimensions']['width'])));
// Check the height. // Check the height.
$this->assertEqual($test['output']['dimensions']['height'], $test['input']['dimensions']['height'], t('Computed height (@computed_height) equals expected height (@expected_height)', array('@computed_height' => $test['output']['dimensions']['height'], '@expected_height' => $test['input']['dimensions']['height']))); $this->assertEqual($test['output']['dimensions']['height'], $test['input']['dimensions']['height'], format_string('Computed height (@computed_height) equals expected height (@expected_height)', array('@computed_height' => $test['output']['dimensions']['height'], '@expected_height' => $test['input']['dimensions']['height'])));
// Check the return value. // Check the return value.
$this->assertEqual($test['output']['return_value'], $return_value, t('Correct return value.')); $this->assertEqual($test['output']['return_value'], $return_value, 'Correct return value.');
} }
} }
} }
...@@ -70,10 +70,10 @@ function testImageDimensions() { ...@@ -70,10 +70,10 @@ function testImageDimensions() {
image_effect_save('test', $effect); image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="120" height="60" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="120" height="60" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri); $image_info = image_get_info($generated_uri);
$this->assertEqual($image_info['width'], 120); $this->assertEqual($image_info['width'], 120);
$this->assertEqual($image_info['height'], 60); $this->assertEqual($image_info['height'], 60);
...@@ -91,10 +91,10 @@ function testImageDimensions() { ...@@ -91,10 +91,10 @@ function testImageDimensions() {
image_effect_save('test', $effect); image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="60" height="120" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="60" height="120" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri); $image_info = image_get_info($generated_uri);
$this->assertEqual($image_info['width'], 60); $this->assertEqual($image_info['width'], 60);
$this->assertEqual($image_info['height'], 120); $this->assertEqual($image_info['height'], 120);
...@@ -113,10 +113,10 @@ function testImageDimensions() { ...@@ -113,10 +113,10 @@ function testImageDimensions() {
image_effect_save('test', $effect); image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="45" height="90" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="45" height="90" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri); $image_info = image_get_info($generated_uri);
$this->assertEqual($image_info['width'], 45); $this->assertEqual($image_info['width'], 45);
$this->assertEqual($image_info['height'], 90); $this->assertEqual($image_info['height'], 90);
...@@ -135,10 +135,10 @@ function testImageDimensions() { ...@@ -135,10 +135,10 @@ function testImageDimensions() {
image_effect_save('test', $effect); image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="45" height="90" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="45" height="90" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri); $image_info = image_get_info($generated_uri);
$this->assertEqual($image_info['width'], 45); $this->assertEqual($image_info['width'], 45);
$this->assertEqual($image_info['height'], 90); $this->assertEqual($image_info['height'], 90);
...@@ -153,10 +153,10 @@ function testImageDimensions() { ...@@ -153,10 +153,10 @@ function testImageDimensions() {
image_effect_save('test', $effect); image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="45" height="90" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="45" height="90" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri); $image_info = image_get_info($generated_uri);
$this->assertEqual($image_info['width'], 45); $this->assertEqual($image_info['width'], 45);
$this->assertEqual($image_info['height'], 90); $this->assertEqual($image_info['height'], 90);
...@@ -174,10 +174,10 @@ function testImageDimensions() { ...@@ -174,10 +174,10 @@ function testImageDimensions() {
image_effect_save('test', $effect); image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
// Add a crop effect. // Add a crop effect.
...@@ -194,10 +194,10 @@ function testImageDimensions() { ...@@ -194,10 +194,10 @@ function testImageDimensions() {
image_effect_save('test', $effect); image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="30" height="30" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="30" height="30" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri); $image_info = image_get_info($generated_uri);
$this->assertEqual($image_info['width'], 30); $this->assertEqual($image_info['width'], 30);
$this->assertEqual($image_info['height'], 30); $this->assertEqual($image_info['height'], 30);
...@@ -215,10 +215,10 @@ function testImageDimensions() { ...@@ -215,10 +215,10 @@ function testImageDimensions() {
$effect = image_effect_save('test', $effect); $effect = image_effect_save('test', $effect);
$img_tag = theme_image_style($variables); $img_tag = theme_image_style($variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" alt="" />'); $this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" alt="" />');
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url); $this->drupalGet($url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
image_effect_delete('test', $effect); image_effect_delete('test', $effect);
......
...@@ -40,13 +40,13 @@ function setUp() { ...@@ -40,13 +40,13 @@ function setUp() {
* Test the image_resize_effect() function. * Test the image_resize_effect() function.
*/ */
function testResizeEffect() { function testResizeEffect() {
$this->assertTrue(image_resize_effect($this->image, array('width' => 1, 'height' => 2)), t('Function returned the expected value.')); $this->assertTrue(image_resize_effect($this->image, array('width' => 1, 'height' => 2)), 'Function returned the expected value.');
$this->assertToolkitOperationsCalled(array('resize')); $this->assertToolkitOperationsCalled(array('resize'));
// Check the parameters. // Check the parameters.
$calls = image_test_get_all_calls(); $calls = image_test_get_all_calls();
$this->assertEqual($calls['resize'][0][1], 1, t('Width was passed correctly')); $this->assertEqual($calls['resize'][0][1], 1, 'Width was passed correctly');
$this->assertEqual($calls['resize'][0][2], 2, t('Height was passed correctly')); $this->assertEqual($calls['resize'][0][2], 2, 'Height was passed correctly');
} }
/** /**
...@@ -54,13 +54,13 @@ function testResizeEffect() { ...@@ -54,13 +54,13 @@ function testResizeEffect() {
*/ */
function testScaleEffect() { function testScaleEffect() {
// @todo: need to test upscaling. // @todo: need to test upscaling.
$this->assertTrue(image_scale_effect($this->image, array('width' => 10, 'height' => 10)), t('Function returned the expected value.')); $this->assertTrue(image_scale_effect($this->image, array('width' => 10, 'height' => 10)), 'Function returned the expected value.');
$this->assertToolkitOperationsCalled(array('resize')); $this->assertToolkitOperationsCalled(array('resize'));
// Check the parameters. // Check the parameters.
$calls = image_test_get_all_calls(); $calls = image_test_get_all_calls();
$this->assertEqual($calls['resize'][0][1], 10, t('Width was passed correctly')); $this->assertEqual($calls['resize'][0][1], 10, 'Width was passed correctly');
$this->assertEqual($calls['resize'][0][2], 5, t('Height was based off aspect ratio and passed correctly')); $this->assertEqual($calls['resize'][0][2], 5, 'Height was based off aspect ratio and passed correctly');
} }
/** /**
...@@ -68,42 +68,42 @@ function testScaleEffect() { ...@@ -68,42 +68,42 @@ function testScaleEffect() {
*/ */
function testCropEffect() { function testCropEffect() {
// @todo should test the keyword offsets. // @todo should test the keyword offsets.
$this->assertTrue(image_crop_effect($this->image, array('anchor' => 'top-1', 'width' => 3, 'height' => 4)), t('Function returned the expected value.')); $this->assertTrue(image_crop_effect($this->image, array('anchor' => 'top-1', 'width' => 3, 'height' => 4)), 'Function returned the expected value.');
$this->assertToolkitOperationsCalled(array('crop')); $this->assertToolkitOperationsCalled(array('crop'));
// Check the parameters. // Check the parameters.
$calls = image_test_get_all_calls(); $calls = image_test_get_all_calls();
$this->assertEqual($calls['crop'][0][1], 0, t('X was passed correctly')); $this->assertEqual($calls['crop'][0][1], 0, 'X was passed correctly');
$this->assertEqual($calls['crop'][0][2], 1, t('Y was passed correctly')); $this->assertEqual($calls['crop'][0][2], 1, 'Y was passed correctly');
$this->assertEqual($calls['crop'][0][3], 3, t('Width was passed correctly')); $this->assertEqual($calls['crop'][0][3], 3, 'Width was passed correctly');
$this->assertEqual($calls['crop'][0][4], 4, t('Height was passed correctly')); $this->assertEqual($calls['crop'][0][4], 4, 'Height was passed correctly');
} }
/** /**
* Test the image_scale_and_crop_effect() function. * Test the image_scale_and_crop_effect() function.
*/ */
function testScaleAndCropEffect() { function testScaleAndCropEffect() {
$this->assertTrue(image_scale_and_crop_effect($this->image, array('width' => 5, 'height' => 10)), t('Function returned the expected value.')); $this->assertTrue(image_scale_and_crop_effect($this->image, array('width' => 5, 'height' => 10)), 'Function returned the expected value.');
$this->assertToolkitOperationsCalled(array('resize', 'crop')); $this->assertToolkitOperationsCalled(array('resize', 'crop'));
// Check the parameters. // Check the parameters.
$calls = image_test_get_all_calls(); $calls = image_test_get_all_calls();
$this->assertEqual($calls['crop'][0][1], 7.5, t('X was computed and passed correctly')); $this->assertEqual($calls['crop'][0][1], 7.5, 'X was computed and passed correctly');
$this->assertEqual($calls['crop'][0][2], 0, t('Y was computed and passed correctly')); $this->assertEqual($calls['crop'][0][2], 0, 'Y was computed and passed correctly');
$this->assertEqual($calls['crop'][0][3], 5, t('Width was computed and passed correctly')); $this->assertEqual($calls['crop'][0][3], 5, 'Width was computed and passed correctly');
$this->assertEqual($calls['crop'][0][4], 10, t('Height was computed and passed correctly')); $this->assertEqual($calls['crop'][0][4], 10, 'Height was computed and passed correctly');
} }
/** /**
* Test the image_desaturate_effect() function. * Test the image_desaturate_effect() function.
*/ */
function testDesaturateEffect() { function testDesaturateEffect() {
$this->assertTrue(image_desaturate_effect($this->image, array()), t('Function returned the expected value.')); $this->assertTrue(image_desaturate_effect($this->image, array()), 'Function returned the expected value.');
$this->assertToolkitOperationsCalled(array('desaturate')); $this->assertToolkitOperationsCalled(array('desaturate'));
// Check the parameters. // Check the parameters.
$calls = image_test_get_all_calls(); $calls = image_test_get_all_calls();
$this->assertEqual(count($calls['desaturate'][0]), 1, t('Only the image was passed.')); $this->assertEqual(count($calls['desaturate'][0]), 1, 'Only the image was passed.');
} }
/** /**
...@@ -111,13 +111,13 @@ function testDesaturateEffect() { ...@@ -111,13 +111,13 @@ function testDesaturateEffect() {
*/ */
function testRotateEffect() { function testRotateEffect() {
// @todo: need to test with 'random' => TRUE // @todo: need to test with 'random' => TRUE
$this->assertTrue(image_rotate_effect($this->image, array('degrees' => 90, 'bgcolor' => '#fff')), t('Function returned the expected value.')); $this->assertTrue(image_rotate_effect($this->image, array('degrees' => 90, 'bgcolor' => '#fff')), 'Function returned the expected value.');
$this->assertToolkitOperationsCalled(array('rotate')); $this->assertToolkitOperationsCalled(array('rotate'));
// Check the parameters. // Check the parameters.
$calls = image_test_get_all_calls(); $calls = image_test_get_all_calls();
$this->assertEqual($calls['rotate'][0][1], 90, t('Degrees were passed correctly')); $this->assertEqual($calls['rotate'][0][1], 90, 'Degrees were passed correctly');
$this->assertEqual($calls['rotate'][0][2], 0xffffff, t('Background color was passed correctly')); $this->assertEqual($calls['rotate'][0][2], 0xffffff, 'Background color was passed correctly');
} }
/** /**
......
...@@ -49,8 +49,8 @@ function testResolution() { ...@@ -49,8 +49,8 @@ function testResolution() {
} }
} }
$nid = $this->uploadNodeImage($image_that_is_too_small, $field_name, 'article'); $nid = $this->uploadNodeImage($image_that_is_too_small, $field_name, 'article');
$this->assertText(t('The specified file ' . $image_that_is_too_small->filename . ' could not be uploaded. The image is too small; the minimum dimensions are 50x50 pixels.'), t('Node save failed when minimum image resolution was not met.')); $this->assertText(t('The specified file ' . $image_that_is_too_small->filename . ' could not be uploaded. The image is too small; the minimum dimensions are 50x50 pixels.'), 'Node save failed when minimum image resolution was not met.');
$nid = $this->uploadNodeImage($image_that_is_too_big, $field_name, 'article'); $nid = $this->uploadNodeImage($image_that_is_too_big, $field_name, 'article');
$this->assertText(t('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'), t('Image exceeding max resolution was properly resized.')); $this->assertText(t('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'), 'Image exceeding max resolution was properly resized.');
} }
} }
...@@ -47,11 +47,11 @@ function testImageStylePath() { ...@@ -47,11 +47,11 @@ function testImageStylePath() {
$scheme = 'public'; $scheme = 'public';
$actual = image_style_path($this->style_name, "$scheme://foo/bar.gif"); $actual = image_style_path($this->style_name, "$scheme://foo/bar.gif");
$expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif"; $expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif";
$this->assertEqual($actual, $expected, t('Got the path for a file URI.')); $this->assertEqual($actual, $expected, 'Got the path for a file URI.');
$actual = image_style_path($this->style_name, 'foo/bar.gif'); $actual = image_style_path($this->style_name, 'foo/bar.gif');
$expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif"; $expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif";
$this->assertEqual($actual, $expected, t('Got the path for a relative file path.')); $this->assertEqual($actual, $expected, 'Got the path for a relative file path.');
} }
/** /**
...@@ -96,7 +96,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE) { ...@@ -96,7 +96,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE) {
// Create the directories for the styles. // Create the directories for the styles.
$directory = $scheme . '://styles/' . $this->style_name; $directory = $scheme . '://styles/' . $this->style_name;
$status = file_prepare_directory($directory, FILE_CREATE_DIRECTORY); $status = file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
$this->assertNotIdentical(FALSE, $status, t('Created the directory for the generated images for the test style.')); $this->assertNotIdentical(FALSE, $status, 'Created the directory for the generated images for the test style.');
// Create a working copy of the file. // Create a working copy of the file.
$files = $this->drupalGetTestFiles('image'); $files = $this->drupalGetTestFiles('image');
...@@ -106,11 +106,11 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE) { ...@@ -106,11 +106,11 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE) {
// Let the image_module_test module know about this file, so it can claim // Let the image_module_test module know about this file, so it can claim
// ownership in hook_file_download(). // ownership in hook_file_download().
variable_set('image_module_test_file_download', $original_uri); variable_set('image_module_test_file_download', $original_uri);
$this->assertNotIdentical(FALSE, $original_uri, t('Created the generated image file.')); $this->assertNotIdentical(FALSE, $original_uri, 'Created the generated image file.');
// Get the URL of a file that has not been generated and try to create it. // Get the URL of a file that has not been generated and try to create it.
$generated_uri = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. drupal_basename($original_uri); $generated_uri = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. drupal_basename($original_uri);
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$generate_url = image_style_url($this->style_name, $original_uri); $generate_url = image_style_url($this->style_name, $original_uri);
if ($GLOBALS['script_path']) { if ($GLOBALS['script_path']) {
...@@ -119,32 +119,32 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE) { ...@@ -119,32 +119,32 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE) {
// Fetch the URL that generates the file. // Fetch the URL that generates the file.
$this->drupalGet($generate_url); $this->drupalGet($generate_url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.')); $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertRaw(file_get_contents($generated_uri), t('URL returns expected file.')); $this->assertRaw(file_get_contents($generated_uri), 'URL returns expected file.');
$generated_image_info = image_get_info($generated_uri); $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-Type'), $generated_image_info['mime_type'], 'Expected Content-Type was reported.');
$this->assertEqual($this->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], t('Expected Content-Length was reported.')); $this->assertEqual($this->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], 'Expected Content-Length was reported.');
if ($scheme == 'private') { if ($scheme == 'private') {
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, private', t('Cache-Control header was set to prevent caching.')); $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, private', 'Cache-Control header was set to prevent caching.');
$this->assertEqual($this->drupalGetHeader('X-Image-Owned-By'), 'image_module_test', t('Expected custom header has been added.')); $this->assertEqual($this->drupalGetHeader('X-Image-Owned-By'), 'image_module_test', 'Expected custom header has been added.');
// Make sure that a second request to the already existing derivate works // Make sure that a second request to the already existing derivate works
// too. // too.
$this->drupalGet($generate_url); $this->drupalGet($generate_url);
$this->assertResponse(200, t('Image was generated at the URL.')); $this->assertResponse(200, 'Image was generated at the URL.');
// Repeat this with a different file that we do not have access to and // Repeat this with a different file that we do not have access to and
// make sure that access is denied. // make sure that access is denied.
$file_noaccess = array_shift($files); $file_noaccess = array_shift($files);
$original_uri_noaccess = file_unmanaged_copy($file_noaccess->uri, $scheme . '://', FILE_EXISTS_RENAME); $original_uri_noaccess = file_unmanaged_copy($file_noaccess->uri, $scheme . '://', FILE_EXISTS_RENAME);
$generated_uri_noaccess = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. drupal_basename($original_uri_noaccess); $generated_uri_noaccess = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. drupal_basename($original_uri_noaccess);
$this->assertFalse(file_exists($generated_uri_noaccess), t('Generated file does not exist.')); $this->assertFalse(file_exists($generated_uri_noaccess), 'Generated file does not exist.');
$generate_url_noaccess = image_style_url($this->style_name, $original_uri_noaccess); $generate_url_noaccess = image_style_url($this->style_name, $original_uri_noaccess);
$this->drupalGet($generate_url_noaccess); $this->drupalGet($generate_url_noaccess);
$this->assertResponse(403, t('Confirmed that access is denied for the private image style.') ); $this->assertResponse(403, 'Confirmed that access is denied for the private image style.');
// Verify that images are not appended to the response. Currently this test only uses PNG images. // Verify that images are not appended to the response. Currently this test only uses PNG images.
if (strpos($generate_url, '.png') === FALSE ) { if (strpos($generate_url, '.png') === FALSE ) {
$this->fail('Confirming that private image styles are not appended require PNG file.'); $this->fail('Confirming that private image styles are not appended require PNG file.');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment