WordPress.org

Make WordPress Core

Changeset 49010


Ignore:
Timestamp:
09/20/2020 03:31:46 AM (2 months ago)
Author:
SergeyBiryukov
Message:

Tests: Consistently require imagejpeg() function in image_make_intermediate_size() tests.

This outputs a proper message if the requirement is not met, instead of an obscure PHP error further in the test.

See #50639, #50640.

File:
1 edited

Legend:

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

    r48937 r49010  
    7070     */
    7171    function test_get_intermediate_sizes_by_name() {
     72        if ( ! function_exists( 'imagejpeg' ) ) {
     73            $this->fail( 'jpeg support unavailable' );
     74        }
     75
    7276        add_image_size( 'test-size', 330, 220, true );
    7377
     
    9094     */
    9195    function test_get_intermediate_sizes_by_array_exact() {
     96        if ( ! function_exists( 'imagejpeg' ) ) {
     97            $this->fail( 'jpeg support unavailable' );
     98        }
     99
    92100        // Only one dimention match shouldn't return false positive (see: #17626).
    93101        add_image_size( 'test-size', 330, 220, true );
     
    111119     */
    112120    function test_get_intermediate_sizes_by_array_nearest() {
     121        if ( ! function_exists( 'imagejpeg' ) ) {
     122            $this->fail( 'jpeg support unavailable' );
     123        }
     124
    113125        // If an exact size is not found, it should be returned.
    114126        // If not, find nearest size that is larger (see: #17626).
     
    154166     */
    155167    function test_get_intermediate_sizes_by_array_zero_height() {
     168        if ( ! function_exists( 'imagejpeg' ) ) {
     169            $this->fail( 'jpeg support unavailable' );
     170        }
     171
    156172        // Generate random width.
    157173        $random_w = rand( 300, 400 );
     
    182198     */
    183199    function test_get_intermediate_sizes_by_array_zero_width() {
     200        if ( ! function_exists( 'imagejpeg' ) ) {
     201            $this->fail( 'jpeg support unavailable' );
     202        }
     203
    184204        // 202 is the smallest height that will trigger a miss for 'false-height'.
    185205        $height = 202;
     
    210230     */
    211231    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
    212236        // Original is 600x400. 300x201 is close enough to match.
    213237        $width  = 300;
     
    233257     */
    234258    public function test_get_intermediate_size_with_small_size_array() {
     259        if ( ! function_exists( 'imagejpeg' ) ) {
     260            $this->fail( 'jpeg support unavailable' );
     261        }
     262
    235263        // Add a hard cropped size that matches the aspect ratio we're going to test.
    236264        add_image_size( 'test-size', 200, 100, true );
     
    250278     */
    251279    public function test_get_intermediate_size_with_small_size_array_fallback() {
     280        if ( ! function_exists( 'imagejpeg' ) ) {
     281            $this->fail( 'jpeg support unavailable' );
     282        }
     283
    252284        $file = DIR_TESTDATA . '/images/waffles.jpg';
    253285        $id   = $this->_make_attachment( $file, 0 );
Note: See TracChangeset for help on using the changeset viewer.