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

See #40364.

git-svn-id: https://develop.svn.wordpress.org/trunk@47313 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-02-19 02:41:53 +00:00
parent efde364e7c
commit 8de22575cd

View File

@ -405,11 +405,11 @@ if ( is_multisite() ) :
wpmu_update_blogs_date();
$blog = get_site( get_current_blog_id() );
$current_time = time();
// Compare the update time with the current time, allow delta < 2.
$blog = get_site( get_current_blog_id() );
$current_time = time();
$time_difference = $current_time - strtotime( $blog->last_updated );
$this->assertLessThan( 2, $time_difference );
$this->assertEquals( $current_time, strtotime( $blog->last_updated ), 'The dates should be equal', 2 );
}
/**
@ -1766,16 +1766,16 @@ if ( is_multisite() ) :
$this->assertInternalType( 'integer', $site_id );
$site = get_site( $site_id );
$this->assertSame( $first_date, $site->registered );
$this->assertSame( $first_date, $site->last_updated );
$this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
$this->assertSame( strtotime( $first_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
$second_date = current_time( 'mysql', true );
$site_id = wp_update_site( $site_id, array() );
$this->assertInternalType( 'integer', $site_id );
$site = get_site( $site_id );
$this->assertSame( $first_date, $site->registered );
$this->assertSame( $second_date, $site->last_updated );
$this->assertSame( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
$this->assertSame( strtotime( $second_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
}
/**