WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/22/2021 12:58:46 PM (5 months ago)
Author:
SergeyBiryukov
Message:

Media: Some documentation and test improvements for the image_editor_output_format filter:

  • Update the filter DocBlock per the documentation standards.
  • Use a shorter variable name for consistency with the surrounding code.
  • Delete the test file before performing assertions to avoid leftovers in case the test fails.

Follow-up to [50943].

See #52867.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/intermediateSize.php

    r50943 r50951  
    5353        $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true );
    5454
     55        unlink( DIR_TESTDATA . '/images/a2-small-100x75.jpg' );
     56
    5557        $this->assertInternalType( 'array', $image );
    5658        $this->assertSame( 100, $image['width'] );
     
    5961
    6062        $this->assertFalse( isset( $image['path'] ) );
    61 
    62         unlink( DIR_TESTDATA . '/images/a2-small-100x75.jpg' );
    63     }
    64 
    65     /**
    66      * @requires function imagejpeg
     63    }
     64
     65    /**
    6766     * @ticket 52867
     67     * @requires function imagejpeg
    6868     */
    6969    function test_image_editor_output_format_filter() {
     
    7474            }
    7575        );
     76
    7677        $file   = DIR_TESTDATA . '/images/waffles.jpg';
    7778        $image  = image_make_intermediate_size( $file, 100, 75, true );
    7879        $editor = wp_get_image_editor( $file );
     80
     81        unlink( DIR_TESTDATA . '/images/' . $image['file'] );
     82        remove_all_filters( 'image_editor_output_format' );
     83
    7984        if ( is_wp_error( $editor ) || ! $editor->supports_mime_type( 'image/webp' ) ) {
    8085            $this->assertSame( 'image/jpeg', $image['mime-type'] );
     
    8287            $this->assertSame( 'image/webp', $image['mime-type'] );
    8388        }
    84         unlink( DIR_TESTDATA . '/images/' . $image['file'] );
    85         remove_all_filters( 'image_editor_output_format' );
    8689    }
    8790
Note: See TracChangeset for help on using the changeset viewer.