Make WordPress Core

Changeset 49520 for branches/4.8


Ignore:
Timestamp:
11/06/2020 04:52:40 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 4.8 branch.
See #46073, #48301.

Location:
branches/4.8
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/tests/phpunit/tests/image/editor_imagick.php

    r40123 r49520  
    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 );
     
    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 );
     
    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 );
     
    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 );
     
    466466
    467467        $this->assertNotInstanceOf( 'WP_Error', $editor );
    468        
     468
    469469        $editor->load();
    470470        $editor->resize( 5, 5 );
Note: See TracChangeset for help on using the changeset viewer.