mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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 git-svn-id: https://develop.svn.wordpress.org/trunk@30337 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -144,7 +144,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function flush_cache() {
|
||||
global $wp_object_cache;
|
||||
$wp_object_cache->group_ops = array();
|
||||
@@ -476,4 +476,12 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
$files = $this->files_in_dir( $uploads['basedir'] );
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to Convert a microtime string into a float
|
||||
*/
|
||||
protected function _microtime_to_float($microtime ){
|
||||
$time_array = explode( ' ', $microtime );
|
||||
return array_sum( $time_array );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user