WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/13/2014 10:03:15 PM (5 years ago)
Author:
jorbin
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.

fixes #30336

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r30276 r30337  
    145145        }
    146146    }
    147    
     147
    148148    function flush_cache() {
    149149        global $wp_object_cache;
     
    477477        return $files;
    478478    }
     479
     480    /**
     481     * Helper to Convert a microtime string into a float
     482     */
     483    protected function _microtime_to_float($microtime ){
     484        $time_array = explode( ' ', $microtime );
     485        return array_sum( $time_array );
     486    }
    479487}
Note: See TracChangeset for help on using the changeset viewer.