Make WordPress Core

Changeset 47313


Ignore:
Timestamp:
02/19/2020 02:41:53 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use delta comparison in test_site_dates_are_gmt() to avoid race conditions.

See #40364.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/site.php

    r47122 r47313  
    406406                        wpmu_update_blogs_date();
    407407
     408                        $blog         = get_site( get_current_blog_id() );
     409                        $current_time = time();
     410
    408411                        // Compare the update time with the current time, allow delta < 2.
    409                         $blog            = get_site( get_current_blog_id() );
    410                         $current_time    = time();
    411                         $time_difference = $current_time - strtotime( $blog->last_updated );
    412                         $this->assertLessThan( 2, $time_difference );
     412                        $this->assertEquals( $current_time, strtotime( $blog->last_updated ), 'The dates should be equal', 2 );
    413413                }
    414414
     
    17671767
    17681768                        $site = get_site( $site_id );
    1769                         $this->assertSame( $first_date, $site->registered );
    1770                         $this->assertSame( $first_date, $site->last_updated );
     1769                        $this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
     1770                        $this->assertSame( strtotime( $first_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
    17711771
    17721772                        $second_date = current_time( 'mysql', true );
     
    17751775
    17761776                        $site = get_site( $site_id );
    1777                         $this->assertSame( $first_date, $site->registered );
    1778                         $this->assertSame( $second_date, $site->last_updated );
     1777                        $this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
     1778                        $this->assertSame( strtotime( $second_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
    17791779                }
    17801780
Note: See TracChangeset for help on using the changeset viewer.