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

Props keesiemeijer.
Fixes #38815.

git-svn-id: https://develop.svn.wordpress.org/trunk@41920 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2017-10-18 19:41:46 +00:00
parent 349ccdf2d7
commit dcb6ef8aa4
1 changed files with 4 additions and 4 deletions

View File

@ -81,8 +81,8 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
function test_get_gmt_from_date_string_date() {
update_option( 'timezone_string', 'Europe/London' );
$local = 'now';
$gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) );
$this->assertEquals( $gmt, get_gmt_from_date( $local ) );
$gmt = gmdate( 'Y-m-d H:i:s' );
$this->assertEquals( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 'The dates should be equal', 2 );
}
/**
@ -90,7 +90,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
*/
function test_get_gmt_from_date_string_date_no_timezone() {
$local = 'now';
$gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) );
$this->assertEquals( $gmt, get_gmt_from_date( $local ) );
$gmt = gmdate( 'Y-m-d H:i:s' );
$this->assertEquals( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 'The dates should be equal', 2 );
}
}