Make WordPress Core


Ignore:
Timestamp:
03/22/2020 02:44:14 PM (5 years ago)
Author:
SergeyBiryukov
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.

Props jorbin.
Merges [30337] to the 3.7 branch.
See #30336, #49485.

Location:
branches/3.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/tests/phpunit/includes/testcase.php

    r47343 r47492  
    163163        }
    164164    }
    165    
     165
    166166    function flush_cache() {
    167167        global $wp_object_cache;
     
    466466        return $files;
    467467    }
     468
     469    /**
     470     * Helper to Convert a microtime string into a float
     471     */
     472    protected function _microtime_to_float($microtime ){
     473        $time_array = explode( ' ', $microtime );
     474        return array_sum( $time_array );
     475    }
    468476}
Note: See TracChangeset for help on using the changeset viewer.