summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJonathan Desrosiers <desrosj@git.wordpress.org>2020-11-06 16:52:40 +0000
committerJonathan Desrosiers <desrosj@git.wordpress.org>2020-11-06 16:52:40 +0000
commitdaef06b2999f7fa05c0ef2d132c98adff794e1fb (patch)
treecdc7c68b1349318633fd11605ba08bc60400df47
parente7c698c42896b79bb86811c4952ba80711ec4be0 (diff)
downloadwordpress-daef06b2999f7fa05c0ef2d132c98adff794e1fb.tar.gz
wordpress-daef06b2999f7fa05c0ef2d132c98adff794e1fb.zip
Media: Improve and fix rotate/flip image tests.
Fix off-by-one error in pixel color checks for rotate and flip image tests. Change to using PNG with single pixel to ensure that errors are caught in the future, rather than lost in JPEG noise. Props Fuegas, mikeschroder. Merges [45067] to the 4.8 branch. See #46073, #48301. git-svn-id: https://develop.svn.wordpress.org/branches/4.8@49520 602fd350-edb4-49c9-b593-d223f7449a82
-rw-r--r--tests/phpunit/data/images/one-blue-pixel-100x100.pngbin0 -> 320 bytes
-rw-r--r--tests/phpunit/tests/image/editor_imagick.php10
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/phpunit/data/images/one-blue-pixel-100x100.png b/tests/phpunit/data/images/one-blue-pixel-100x100.png
new file mode 100644
index 0000000000..1aff0e0ca0
--- /dev/null
+++ b/tests/phpunit/data/images/one-blue-pixel-100x100.png
Binary files differ
diff --git a/tests/phpunit/tests/image/editor_imagick.php b/tests/phpunit/tests/image/editor_imagick.php
index e113b77937..bb35ef3686 100644
--- a/tests/phpunit/tests/image/editor_imagick.php
+++ b/tests/phpunit/tests/image/editor_imagick.php
@@ -420,7 +420,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
* Test rotating an image 180 deg
*/
public function test_rotate() {
- $file = DIR_TESTDATA . '/images/gradient-square.jpg';
+ $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
$imagick_image_editor->load();
@@ -428,7 +428,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
$property->setAccessible( true );
- $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
+ $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
$imagick_image_editor->rotate( 180 );
@@ -439,7 +439,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
* Test flipping an image
*/
public function test_flip() {
- $file = DIR_TESTDATA . '/images/gradient-square.jpg';
+ $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
$imagick_image_editor->load();
@@ -447,7 +447,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
$property->setAccessible( true );
- $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
+ $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
$imagick_image_editor->flip( true, false );
@@ -465,7 +465,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$editor = new WP_Image_Editor_Imagick( $file );
$this->assertNotInstanceOf( 'WP_Error', $editor );
-
+
$editor->load();
$editor->resize( 5, 5 );
$save_to_file = tempnam( get_temp_dir(), '' ) . '.png';