Make WordPress Core


Ignore:
Timestamp:
09/21/2020 11:34:06 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Tests: Convert the checks for imagejpeg() function availability to use the @requires annotation.

This better utilizes the PHPUnit native functionality.

Props ayeshrajans, jrf, johnbillion.
Fixes #50639. See #50640.

File:
1 edited

Legend:

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

    r49010 r49024  
    2929    }
    3030
     31    /**
     32     * @requires function imagejpeg
     33     */
    3134    function test_make_intermediate_size_width() {
    32         if ( ! function_exists( 'imagejpeg' ) ) {
    33             $this->fail( 'jpeg support unavailable' );
    34         }
    35 
    3635        $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false );
    3736
     
    3938    }
    4039
     40    /**
     41     * @requires function imagejpeg
     42     */
    4143    function test_make_intermediate_size_height() {
    42         if ( ! function_exists( 'imagejpeg' ) ) {
    43             $this->fail( 'jpeg support unavailable' );
    44         }
    45 
    4644        $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false );
    4745
     
    4947    }
    5048
     49    /**
     50     * @requires function imagejpeg
     51     */
    5152    function test_make_intermediate_size_successful() {
    52         if ( ! function_exists( 'imagejpeg' ) ) {
    53             $this->fail( 'jpeg support unavailable' );
    54         }
    55 
    5653        $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true );
    5754
     
    6865    /**
    6966     * @ticket 17626
     67     * @requires function imagejpeg
    7068     */
    7169    function test_get_intermediate_sizes_by_name() {
    72         if ( ! function_exists( 'imagejpeg' ) ) {
    73             $this->fail( 'jpeg support unavailable' );
    74         }
    75 
    7670        add_image_size( 'test-size', 330, 220, true );
    7771
     
    9286    /**
    9387     * @ticket 17626
     88     * @requires function imagejpeg
    9489     */
    9590    function test_get_intermediate_sizes_by_array_exact() {
    96         if ( ! function_exists( 'imagejpeg' ) ) {
    97             $this->fail( 'jpeg support unavailable' );
    98         }
    99 
    10091        // Only one dimention match shouldn't return false positive (see: #17626).
    10192        add_image_size( 'test-size', 330, 220, true );
     
    117108    /**
    118109     * @ticket 17626
     110     * @requires function imagejpeg
    119111     */
    120112    function test_get_intermediate_sizes_by_array_nearest() {
    121         if ( ! function_exists( 'imagejpeg' ) ) {
    122             $this->fail( 'jpeg support unavailable' );
    123         }
    124 
    125113        // If an exact size is not found, it should be returned.
    126114        // If not, find nearest size that is larger (see: #17626).
     
    164152    /**
    165153     * @ticket 17626
     154     * @requires function imagejpeg
    166155     */
    167156    function test_get_intermediate_sizes_by_array_zero_height() {
    168         if ( ! function_exists( 'imagejpeg' ) ) {
    169             $this->fail( 'jpeg support unavailable' );
    170         }
    171 
    172157        // Generate random width.
    173158        $random_w = rand( 300, 400 );
     
    196181     * @ticket 17626
    197182     * @ticket 34087
     183     * @requires function imagejpeg
    198184     */
    199185    function test_get_intermediate_sizes_by_array_zero_width() {
    200         if ( ! function_exists( 'imagejpeg' ) ) {
    201             $this->fail( 'jpeg support unavailable' );
    202         }
    203 
    204186        // 202 is the smallest height that will trigger a miss for 'false-height'.
    205187        $height = 202;
     
    228210     * @ticket 17626
    229211     * @ticket 34087
     212     * @requires function imagejpeg
    230213     */
    231214    public function test_get_intermediate_sizes_should_match_size_with_off_by_one_aspect_ratio() {
    232         if ( ! function_exists( 'imagejpeg' ) ) {
    233             $this->fail( 'jpeg support unavailable' );
    234         }
    235 
    236215        // Original is 600x400. 300x201 is close enough to match.
    237216        $width  = 300;
     
    255234    /**
    256235     * @ticket 34384
     236     * @requires function imagejpeg
    257237     */
    258238    public function test_get_intermediate_size_with_small_size_array() {
    259         if ( ! function_exists( 'imagejpeg' ) ) {
    260             $this->fail( 'jpeg support unavailable' );
    261         }
    262 
    263239        // Add a hard cropped size that matches the aspect ratio we're going to test.
    264240        add_image_size( 'test-size', 200, 100, true );
     
    276252    /**
    277253     * @ticket 34384
     254     * @requires function imagejpeg
    278255     */
    279256    public function test_get_intermediate_size_with_small_size_array_fallback() {
    280         if ( ! function_exists( 'imagejpeg' ) ) {
    281             $this->fail( 'jpeg support unavailable' );
    282         }
    283 
    284257        $file = DIR_TESTDATA . '/images/waffles.jpg';
    285258        $id   = $this->_make_attachment( $file, 0 );
Note: See TracChangeset for help on using the changeset viewer.