From dcb6ef8aa43e020154612aeb07b04e10983caf63 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 18 Oct 2017 19:41:46 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/formatting/date.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/formatting/date.php b/tests/phpunit/tests/formatting/date.php index 2d0fddcc36..02fd8f2e25 100644 --- a/tests/phpunit/tests/formatting/date.php +++ b/tests/phpunit/tests/formatting/date.php @@ -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 ); } }