From 2a7aedc9e08a4a3701f908ffc981ac5a476b493c Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Fri, 29 Mar 2019 02:48:08 +0000 Subject: [PATCH] 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. Fixes #46073. git-svn-id: https://develop.svn.wordpress.org/trunk@45067 602fd350-edb4-49c9-b593-d223f7449a82 --- .../data/images/one-blue-pixel-100x100.png | Bin 0 -> 320 bytes tests/phpunit/tests/image/editorImagick.php | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/data/images/one-blue-pixel-100x100.png 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 0000000000000000000000000000000000000000..1aff0e0ca08b61b27f1e6a41b58368249c65f430 GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0vp^DIm!lvI6;>1s;*b3=DjSL74G){tA%xtDY{7Ar*0NFBmd1FmN1D_&xm^*SmI(GiN?6 v(V8H7f-8k}6H{d48iz0i?V-Z0x^4SRdH;OnS;uYxJ;>nc>gTe~DWM4fmXc+` literal 0 HcmV?d00001 diff --git a/tests/phpunit/tests/image/editorImagick.php b/tests/phpunit/tests/image/editorImagick.php index f62ad39815..ac531ff942 100644 --- a/tests/phpunit/tests/image/editorImagick.php +++ b/tests/phpunit/tests/image/editorImagick.php @@ -421,7 +421,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(); @@ -429,7 +429,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 ); @@ -440,7 +440,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(); @@ -448,7 +448,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 );