Skip to content

Commit a3b1bac

Browse files
Date/Time: Use delta comparison in get_gmt_from_date() tests to avoid race conditions.
Follow-up to [35284]. Props keesiemeijer. Merges [41920] to the 4.7 branch. See #38815. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@51613 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 31e4329 commit a3b1bac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/phpunit/tests/formatting/date.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ function test_get_gmt_from_date_short_date() {
8181
function test_get_gmt_from_date_string_date() {
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

8888
/**
8989
* @ticket 34279
9090
*/
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
}

0 commit comments

Comments
 (0)