WordPress.org

Make WordPress Core

Changeset 49032


Ignore:
Timestamp:
09/22/2020 12:30:48 PM (10 months ago)
Author:
SergeyBiryukov
Message:

Tests: Check if image metadata for a particular size was successfully retrieved in some media tests.

This outputs a proper message in case of failure, instead of an obscure PHP error further in the test.

See #50913.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r48952 r49032  
    14311431
    14321432    /**
    1433      * Helper function to get image size array from size "name"
     1433     * Helper function to get image size array from size "name".
    14341434     */
    14351435    function _get_image_size_array_from_meta( $image_meta, $size_name ) {
     
    14421442                $array = array( $image_meta['sizes'][ $size_name ]['width'], $image_meta['sizes'][ $size_name ]['height'] );
    14431443            }
     1444        }
     1445
     1446        if ( ! $array ) {
     1447            $this->fail( sprintf( "Could not retrieve image metadata for size '%s'.", $size_name ) );
    14441448        }
    14451449
Note: See TracChangeset for help on using the changeset viewer.