security update core+modules
This commit is contained in:
@@ -55,19 +55,19 @@ class ImageToolkitTestCase extends DrupalWebTestCase {
|
||||
// Determine if there were any expected that were not called.
|
||||
$uncalled = array_diff($expected, $actual);
|
||||
if (count($uncalled)) {
|
||||
$this->assertTrue(FALSE, t('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
|
||||
$this->assertTrue(FALSE, format_string('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
|
||||
}
|
||||
else {
|
||||
$this->assertTrue(TRUE, t('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected))));
|
||||
$this->assertTrue(TRUE, format_string('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected))));
|
||||
}
|
||||
|
||||
// Determine if there were any unexpected calls.
|
||||
$unexpected = array_diff($actual, $expected);
|
||||
if (count($unexpected)) {
|
||||
$this->assertTrue(FALSE, t('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected))));
|
||||
$this->assertTrue(FALSE, format_string('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected))));
|
||||
}
|
||||
else {
|
||||
$this->assertTrue(TRUE, t('No unexpected operations were called.'));
|
||||
$this->assertTrue(TRUE, 'No unexpected operations were called.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,8 +90,8 @@ class ImageToolkitUnitTest extends ImageToolkitTestCase {
|
||||
*/
|
||||
function testGetAvailableToolkits() {
|
||||
$toolkits = image_get_available_toolkits();
|
||||
$this->assertTrue(isset($toolkits['test']), t('The working toolkit was returned.'));
|
||||
$this->assertFalse(isset($toolkits['broken']), t('The toolkit marked unavailable was not returned'));
|
||||
$this->assertTrue(isset($toolkits['test']), 'The working toolkit was returned.');
|
||||
$this->assertFalse(isset($toolkits['broken']), 'The toolkit marked unavailable was not returned');
|
||||
$this->assertToolkitOperationsCalled(array());
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ class ImageToolkitUnitTest extends ImageToolkitTestCase {
|
||||
*/
|
||||
function testLoad() {
|
||||
$image = image_load($this->file, $this->toolkit);
|
||||
$this->assertTrue(is_object($image), t('Returned an object.'));
|
||||
$this->assertEqual($this->toolkit, $image->toolkit, t('Image had toolkit set.'));
|
||||
$this->assertTrue(is_object($image), 'Returned an object.');
|
||||
$this->assertEqual($this->toolkit, $image->toolkit, 'Image had toolkit set.');
|
||||
$this->assertToolkitOperationsCalled(array('load', 'get_info'));
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class ImageToolkitUnitTest extends ImageToolkitTestCase {
|
||||
* Test the image_save() function.
|
||||
*/
|
||||
function testSave() {
|
||||
$this->assertFalse(image_save($this->image), t('Function returned the expected value.'));
|
||||
$this->assertFalse(image_save($this->image), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('save'));
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ class ImageToolkitUnitTest extends ImageToolkitTestCase {
|
||||
* Test the image_resize() function.
|
||||
*/
|
||||
function testResize() {
|
||||
$this->assertTrue(image_resize($this->image, 1, 2), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_resize($this->image, 1, 2), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('resize'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['resize'][0][1], 1, t('Width was passed correctly'));
|
||||
$this->assertEqual($calls['resize'][0][2], 2, t('Height was passed correctly'));
|
||||
$this->assertEqual($calls['resize'][0][1], 1, 'Width was passed correctly');
|
||||
$this->assertEqual($calls['resize'][0][2], 2, 'Height was passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,69 +131,69 @@ class ImageToolkitUnitTest extends ImageToolkitTestCase {
|
||||
*/
|
||||
function testScale() {
|
||||
// TODO: need to test upscaling
|
||||
$this->assertTrue(image_scale($this->image, 10, 10), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_scale($this->image, 10, 10), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('resize'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['resize'][0][1], 10, t('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][1], 10, 'Width was passed correctly');
|
||||
$this->assertEqual($calls['resize'][0][2], 5, 'Height was based off aspect ratio and passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the image_scale_and_crop() function.
|
||||
*/
|
||||
function testScaleAndCrop() {
|
||||
$this->assertTrue(image_scale_and_crop($this->image, 5, 10), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_scale_and_crop($this->image, 5, 10), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('resize', 'crop'));
|
||||
|
||||
// Check the parameters.
|
||||
$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][2], 0, t('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][4], 10, t('Height 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, 'Y 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, 'Height was computed and passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the image_rotate() function.
|
||||
*/
|
||||
function testRotate() {
|
||||
$this->assertTrue(image_rotate($this->image, 90, 1), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_rotate($this->image, 90, 1), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('rotate'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['rotate'][0][1], 90, t('Degrees were passed correctly'));
|
||||
$this->assertEqual($calls['rotate'][0][2], 1, t('Background color was passed correctly'));
|
||||
$this->assertEqual($calls['rotate'][0][1], 90, 'Degrees were passed correctly');
|
||||
$this->assertEqual($calls['rotate'][0][2], 1, 'Background color was passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the image_crop() function.
|
||||
*/
|
||||
function testCrop() {
|
||||
$this->assertTrue(image_crop($this->image, 1, 2, 3, 4), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_crop($this->image, 1, 2, 3, 4), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('crop'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['crop'][0][1], 1, t('X was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][2], 2, t('Y was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][3], 3, t('Width was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][4], 4, t('Height was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][1], 1, 'X was passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][2], 2, 'Y was passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][3], 3, 'Width was passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][4], 4, 'Height was passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the image_desaturate() function.
|
||||
*/
|
||||
function testDesaturate() {
|
||||
$this->assertTrue(image_desaturate($this->image), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_desaturate($this->image), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('desaturate'));
|
||||
|
||||
// Check the parameters.
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,6 +261,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
*/
|
||||
function testManipulations() {
|
||||
// If GD isn't available don't bother testing this.
|
||||
module_load_include('inc', 'system', 'image.gd');
|
||||
if (!function_exists('image_gd_check_settings') || !image_gd_check_settings()) {
|
||||
$this->pass(t('Image manipulations for the GD toolkit were skipped because the GD toolkit is not available.'));
|
||||
return;
|
||||
@@ -379,7 +380,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
array_fill(0, 3, 76) + array(3 => 0),
|
||||
array_fill(0, 3, 149) + array(3 => 0),
|
||||
array_fill(0, 3, 29) + array(3 => 0),
|
||||
array_fill(0, 3, 0) + array(3 => 127)
|
||||
array_fill(0, 3, 225) + array(3 => 127)
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -394,11 +395,14 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
// Transparent GIFs and the imagefilter function don't work together.
|
||||
// There is a todo in image.gd.inc to correct this.
|
||||
// All images should be converted to truecolor when loaded.
|
||||
$image_truecolor = imageistruecolor($image->resource);
|
||||
$this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
|
||||
|
||||
if ($image->info['extension'] == 'gif') {
|
||||
if ($op == 'desaturate') {
|
||||
$values['corners'][3] = $this->white;
|
||||
// Transparent GIFs and the imagefilter function don't work together.
|
||||
$values['corners'][3][3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,17 +455,47 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
|
||||
$directory = file_default_scheme() . '://imagetests';
|
||||
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
|
||||
image_save($image, $directory . '/' . $op . '.' . $image->info['extension']);
|
||||
$file_path = $directory . '/' . $op . '.' . $image->info['extension'];
|
||||
image_save($image, $file_path);
|
||||
|
||||
$this->assertTrue($correct_dimensions_real, t('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
|
||||
$this->assertTrue($correct_dimensions_object, t('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
|
||||
$this->assertTrue($correct_dimensions_real, format_string('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
|
||||
$this->assertTrue($correct_dimensions_object, format_string('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
|
||||
// JPEG colors will always be messed up due to compression.
|
||||
if ($image->info['extension'] != 'jpg') {
|
||||
$this->assertTrue($correct_colors, t('Image %file object after %action action has the correct color placement.', array('%file' => $file, '%action' => $op)));
|
||||
$this->assertTrue($correct_colors, format_string('Image %file object after %action action has the correct color placement.', array('%file' => $file, '%action' => $op)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check that saved image reloads without raising PHP errors.
|
||||
$image_reloaded = image_load($file_path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests loading an image whose transparent color index is out of range.
|
||||
*/
|
||||
function testTransparentColorOutOfRange() {
|
||||
// This image was generated by taking an initial image with a palette size
|
||||
// of 6 colors, and setting the transparent color index to 6 (one higher
|
||||
// than the largest allowed index), as follows:
|
||||
// @code
|
||||
// $image = imagecreatefromgif('modules/simpletest/files/image-test.gif');
|
||||
// imagecolortransparent($image, 6);
|
||||
// imagegif($image, 'modules/simpletest/files/image-test-transparent-out-of-range.gif');
|
||||
// @endcode
|
||||
// This allows us to test that an image with an out-of-range color index
|
||||
// can be loaded correctly.
|
||||
$file = 'image-test-transparent-out-of-range.gif';
|
||||
$image = image_load(drupal_get_path('module', 'simpletest') . '/files/' . $file);
|
||||
|
||||
if (!$image) {
|
||||
$this->fail(format_string('Could not load image %file.', array('%file' => $file)));
|
||||
}
|
||||
else {
|
||||
// All images should be converted to truecolor when loaded.
|
||||
$image_truecolor = imageistruecolor($image->resource);
|
||||
$this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user