Make WordPress Core


Ignore:
Timestamp:
05/01/2017 11:42:16 PM (8 years ago)
Author:
johnbillion
Message:

When asserting microtime output as a number, make it a number

microtime is by default a string. Doing a greater then or less than check of that string is a bad idea since it uses the first part (the micro part of microtime) rather then the actual time. This adds a helper to convert microtime output into a float which we can then use to properly compare the output of microtime.

This fixes an intermittent test failure.

See #30336

Merges [30337] to the 4.0 branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0/tests/phpunit/includes/testcase.php

    r40247 r40566  
    125125        }
    126126    }
    127    
     127
    128128    function flush_cache() {
    129129        global $wp_object_cache;
     
    447447        return $files;
    448448    }
     449
     450    /**
     451     * Helper to Convert a microtime string into a float
     452     */
     453    protected function _microtime_to_float($microtime ){
     454        $time_array = explode( ' ', $microtime );
     455        return array_sum( $time_array );
     456    }
    449457}
Note: See TracChangeset for help on using the changeset viewer.