Make WordPress Core

Changeset 49517


Ignore:
Timestamp:
11/06/2020 04:44:34 PM (4 years ago)
Author:
desrosj
Message:

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.1 branch.
See #46073, #48301.

Location:
branches/5.1
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/5.1

  • branches/5.1/tests/phpunit/tests/image/editorImagick.php

    r42863 r49517  
    422422     */
    423423    public function test_rotate() {
    424         $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     424        $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
    425425
    426426        $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
     
    430430        $property->setAccessible( true );
    431431
    432         $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
     432        $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
    433433
    434434        $imagick_image_editor->rotate( 180 );
     
    441441     */
    442442    public function test_flip() {
    443         $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     443        $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
    444444
    445445        $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
     
    449449        $property->setAccessible( true );
    450450
    451         $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
     451        $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
    452452
    453453        $imagick_image_editor->flip( true, false );
Note: See TracChangeset for help on using the changeset viewer.