WordPress.org

Make WordPress Core

Changeset 41920


Ignore:
Timestamp:
10/18/2017 07:41:46 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Date/Time: Use delta comparison in get_gmt_from_date() tests to avoid race conditions.

Props keesiemeijer.
Fixes #38815.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/date.php

    r35284 r41920  
    8282        update_option( 'timezone_string', 'Europe/London' );
    8383        $local = 'now';
    84         $gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) );
    85         $this->assertEquals( $gmt, get_gmt_from_date( $local ) );
     84        $gmt = gmdate( 'Y-m-d H:i:s' );
     85        $this->assertEquals( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 'The dates should be equal', 2 );
    8686    }
    8787
     
    9191    function test_get_gmt_from_date_string_date_no_timezone() {
    9292        $local = 'now';
    93         $gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) );
    94         $this->assertEquals( $gmt, get_gmt_from_date( $local ) );
     93        $gmt = gmdate( 'Y-m-d H:i:s' );
     94        $this->assertEquals( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 'The dates should be equal', 2 );
    9595    }
    9696}
Note: See TracChangeset for help on using the changeset viewer.