From cf498f29f6204be8df6981c187d5dd323cb529de Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Sat, 28 Sep 2013 21:53:52 +0300 Subject: [PATCH] Issue #1579810 by Albert Volkman, claudiu.cristea, SeeSchloss: Fixed GD tests do not test check every case and code cleanup. --- .../system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php | 11 ++++++----- .../system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php index 0e81a77..f7766f1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Image\ImageInterface; use Drupal\simpletest\DrupalUnitTestBase; +use Drupal\Component\Utility\String; /** * Test the core GD image manipulation functions. @@ -222,13 +223,13 @@ function testManipulations() { // Load up a fresh image. $image = $image_factory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file); if (!$image) { - $this->fail(t('Could not load image %file.', array('%file' => $file))); + $this->fail(String::format('Could not load image %file.', array('%file' => $file))); continue 2; } // All images should be converted to truecolor when loaded. $image_truecolor = imageistruecolor($image->getResource()); - $this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file))); + $this->assertTrue($image_truecolor, String::format('Image %file after load is a truecolor image.', array('%file' => $file))); if ($image->getType() == IMAGETYPE_GIF) { if ($op == 'desaturate') { @@ -260,8 +261,8 @@ function testManipulations() { file_prepare_directory($directory, FILE_CREATE_DIRECTORY); $image->save($directory . '/' . $op . '.' . $image->getExtension()); - $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))); + $this->assertTrue($correct_dimensions_real, String::format('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op))); + $this->assertTrue($correct_dimensions_object, String::format('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->getType() != IMAGETYPE_JPEG) { @@ -288,7 +289,7 @@ function testManipulations() { } $color = $this->getPixelColor($image, $x, $y); $correct_colors = $this->colorsAreEqual($color, $corner); - $this->assertTrue($correct_colors, format_string('Image %file object after %action action has the correct color placement at corner %corner.', array('%file' => $file, '%action' => $op, '%corner' => $key))); + $this->assertTrue($correct_colors, String::format('Image %file object after %action action has the correct color placement at corner %corner.', array('%file' => $file, '%action' => $op, '%corner' => $key))); } } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php index a7d097b..45deaea 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php @@ -9,6 +9,7 @@ use Drupal\simpletest\WebTestBase; use Drupal\system\Plugin\ImageToolkitManager; +use Drupal\Component\Utility\String; /** * Base class for image manipulation testing. @@ -90,16 +91,16 @@ function assertToolkitOperationsCalled(array $expected) { // Determine if there were any expected that were not called. $uncalled = array_diff($expected, $actual); if (count($uncalled)) { - $this->assertTrue(FALSE, format_string('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); + $this->assertTrue(FALSE, String::format('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); } else { - $this->assertTrue(TRUE, format_string('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected)))); + $this->assertTrue(TRUE, String::format('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, format_string('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected)))); + $this->assertTrue(FALSE, String::format('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected)))); } else { $this->assertTrue(TRUE, 'No unexpected operations were called.'); -- 1.8.3.1