diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index ebf54cef59..eaf5afbf7e 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -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; } -} \ No newline at end of file + + /** + * Helper to Convert a microtime string into a float + */ + protected function _microtime_to_float($microtime ){ + $time_array = explode( ' ', $microtime ); + return array_sum( $time_array ); + } +} diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index 3e351da7f7..6a8d9342a7 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -79,7 +79,9 @@ class Tests_Post_getPages extends WP_UnitTestCase { // This should bump last_changed. wp_delete_post( $pages[0]->ID ); - $this->assertGreaterThan( $last_changed, wp_cache_get( 'last_changed', 'posts' ) ); + $old_changed_float = $this->_microtime_to_float( $last_changed ); + $new_changed_float = $this->_microtime_to_float( wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertGreaterThan( $old_changed_float, $new_changed_float ); $num_queries = $wpdb->num_queries; $last_changed = wp_cache_get( 'last_changed', 'posts' ); @@ -282,4 +284,4 @@ class Tests_Post_getPages extends WP_UnitTestCase { $pages = get_pages( array( 'child_of' => $page1, 'meta_key' => 'color', 'meta_value' => 'blue' ) ); $this->assertEqualSets( array( $page3 ), wp_list_pluck( $pages, 'ID' ) ); } -} \ No newline at end of file +}