Make WordPress Core

Changeset 51614


Ignore:
Timestamp:
08/15/2021 01:38:32 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.6 branch.
See #38815.

Location:
branches/4.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

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

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