Make WordPress Core


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

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

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

Location:
branches/5.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.1

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

    r44807 r47316  
    392392                        wpmu_update_blogs_date();
    393393
    394                         // compare the update time with the current time, allow delta < 2
    395                         $blog            = get_site( get_current_blog_id() );
    396                         $current_time    = time();
    397                         $time_difference = $current_time - strtotime( $blog->last_updated );
    398                         $this->assertLessThan( 2, $time_difference );
     394                        $blog         = get_site( get_current_blog_id() );
     395                        $current_time = time();
     396
     397                        // Compare the update time with the current time, allow delta < 2.
     398                        $this->assertEquals( $current_time, strtotime( $blog->last_updated ), 'The dates should be equal', 2 );
    399399                }
    400400
     
    17551755
    17561756                        $site = get_site( $site_id );
    1757                         $this->assertSame( $first_date, $site->registered );
    1758                         $this->assertSame( $first_date, $site->last_updated );
     1757                        $this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
     1758                        $this->assertSame( strtotime( $first_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
    17591759
    17601760                        $second_date = current_time( 'mysql', true );
     
    17631763
    17641764                        $site = get_site( $site_id );
    1765                         $this->assertSame( $first_date, $site->registered );
    1766                         $this->assertSame( $second_date, $site->last_updated );
     1765                        $this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
     1766                        $this->assertSame( strtotime( $second_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
    17671767                }
    17681768
Note: See TracChangeset for help on using the changeset viewer.