Skip to content

Commit 83f29fe

Browse files
committed
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 5.0 branch. See #46073, #48301. git-svn-id: https://develop.svn.wordpress.org/branches/5.0@49518 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ba2d11d commit 83f29fe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
320 Bytes
Loading

tests/phpunit/tests/image/editorImagick.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,15 @@ public function test_crop() {
420420
* Test rotating an image 180 deg
421421
*/
422422
public function test_rotate() {
423-
$file = DIR_TESTDATA . '/images/gradient-square.jpg';
423+
$file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
424424

425425
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
426426
$imagick_image_editor->load();
427427

428428
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
429429
$property->setAccessible( true );
430430

431-
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
431+
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
432432

433433
$imagick_image_editor->rotate( 180 );
434434

@@ -439,15 +439,15 @@ public function test_rotate() {
439439
* Test flipping an image
440440
*/
441441
public function test_flip() {
442-
$file = DIR_TESTDATA . '/images/gradient-square.jpg';
442+
$file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
443443

444444
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
445445
$imagick_image_editor->load();
446446

447447
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
448448
$property->setAccessible( true );
449449

450-
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
450+
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
451451

452452
$imagick_image_editor->flip( true, false );
453453

0 commit comments

Comments
 (0)