Make WordPress Core

Changeset 51613 for branches/4.7


Ignore:
Timestamp:
08/15/2021 01:37:58 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/tests/phpunit/tests/formatting/date.php

    r35284 r51613  
    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.