WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/01/2017 11:42:16 PM (2 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/tests/post/getPages.php

    r28399 r40566  
    8080        // This should bump last_changed.
    8181        wp_delete_post( $pages[0]->ID );
    82         $this->assertGreaterThan( $last_changed, wp_cache_get( 'last_changed', 'posts' ) );
     82        $old_changed_float = $this->_microtime_to_float( $last_changed );
     83        $new_changed_float = $this->_microtime_to_float( wp_cache_get( 'last_changed', 'posts' ) );
     84        $this->assertGreaterThan( $old_changed_float, $new_changed_float );
    8385
    8486        $num_queries = $wpdb->num_queries;
Note: See TracChangeset for help on using the changeset viewer.