Make WordPress Core


Ignore:
Timestamp:
12/19/2021 01:42:37 PM (3 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Reduce the use of unnecessary randomness in tests.

This increases the overall reliability of the tests.

Props johnillo

Fixes #37371

File:
1 edited

Legend:

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

    r52010 r52389  
    182182     */
    183183    public function test_get_intermediate_sizes_by_array_zero_height() {
    184         // Generate random width.
    185         $random_w = rand( 300, 400 );
     184        // Use this width.
     185        $width = 300;
    186186
    187187        // Only one dimention match shouldn't return false positive (see: #17626).
    188         add_image_size( 'test-size', $random_w, 0, false );
    189         add_image_size( 'false-height', $random_w, 100, true );
     188        add_image_size( 'test-size', $width, 0, false );
     189        add_image_size( 'false-height', $width, 100, true );
    190190
    191191        $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    193193
    194194        $original = wp_get_attachment_metadata( $id );
    195         $image_w  = $random_w;
     195        $image_w  = $width;
    196196        $image_h  = round( ( $image_w / $original['width'] ) * $original['height'] );
    197197
    198198        // Look for a size by array that exists.
    199199        // Note: Staying larger than 300px to miss default medium crop.
    200         $image = image_get_intermediate_size( $id, array( $random_w, 0 ) );
     200        $image = image_get_intermediate_size( $id, array( $width, 0 ) );
    201201
    202202        // Test for the expected string because the array will by definition
Note: See TracChangeset for help on using the changeset viewer.