WordPress.org

Make WordPress Core

Changeset 47314


Ignore:
Timestamp:
02/19/2020 02:54:55 AM (7 months ago)
Author:
SergeyBiryukov
Message:

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

Merges [47313] to the 5.3 branch.
See #40364.

Location:
branches/5.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

  • branches/5.3/tests/phpunit/tests/multisite/site.php

    r45910 r47314  
    406406            wpmu_update_blogs_date();
    407407
    408             // 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 );
     408            $blog         = get_site( get_current_blog_id() );
     409            $current_time = time();
     410
     411            // Compare the update time with the current time, allow delta < 2.
     412            $this->assertEquals( $current_time, strtotime( $blog->last_updated ), 'The dates should be equal', 2 );
    413413        }
    414414
     
    17691769
    17701770            $site = get_site( $site_id );
    1771             $this->assertSame( $first_date, $site->registered );
    1772             $this->assertSame( $first_date, $site->last_updated );
     1771            $this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
     1772            $this->assertSame( strtotime( $first_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
    17731773
    17741774            $second_date = current_time( 'mysql', true );
     
    17771777
    17781778            $site = get_site( $site_id );
    1779             $this->assertSame( $first_date, $site->registered );
    1780             $this->assertSame( $second_date, $site->last_updated );
     1779            $this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
     1780            $this->assertSame( strtotime( $second_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
    17811781        }
    17821782
Note: See TracChangeset for help on using the changeset viewer.