Skip to content
Permalink
Browse files

REST API: Use delta comparison for floating date tests added in [4625…

…2] to avoid race conditions.

See #39953.

git-svn-id: https://develop.svn.wordpress.org/trunk@46280 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Sep 23, 2019
1 parent b7f36f7 commit 4b6a9f92ca1f883147695147100a8645b351d68c
Showing with 14 additions and 5 deletions.
  1. +14 −5 tests/phpunit/tests/rest-api/rest-posts-controller.php
@@ -4413,6 +4413,9 @@ public function test_generated_permalink_template_generated_slug_for_posts() {
}
/**
* @ticket 39953
*/
public function test_putting_same_publish_date_does_not_remove_floating_date() {
wp_set_current_user( self::$superadmin_id );
@@ -4440,12 +4443,15 @@ public function test_putting_same_publish_date_does_not_remove_floating_date() {
$response = rest_get_server()->dispatch( $put );
$body = $response->get_data();
$this->assertEquals( $get_body['date'], $body['date'] );
$this->assertEquals( $get_body['date_gmt'], $body['date_gmt'] );
$this->assertEquals( strtotime( $get_body['date'] ), strtotime( $body['date'] ), 'The dates should be equal', 2 );
$this->assertEquals( strtotime( $get_body['date_gmt'] ), strtotime( $body['date_gmt'] ), 'The dates should be equal', 2 );
$this->assertEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
}
/**
* @ticket 39953
*/
public function test_putting_different_publish_date_removes_floating_date() {
wp_set_current_user( self::$superadmin_id );
@@ -4481,11 +4487,14 @@ public function test_putting_different_publish_date_removes_floating_date() {
$response = rest_get_server()->dispatch( $put );
$body = $response->get_data();
$this->assertEquals( mysql_to_rfc3339( $new_time ), $body['date'] );
$this->assertEquals( strtotime( mysql_to_rfc3339( $new_time ) ), strtotime( $body['date'] ), 'The dates should be equal', 2 );
$this->assertNotEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
}
/**
* @ticket 39953
*/
public function test_publishing_post_with_same_date_removes_floating_date() {
wp_set_current_user( self::$superadmin_id );
@@ -4520,8 +4529,8 @@ public function test_publishing_post_with_same_date_removes_floating_date() {
$response = rest_get_server()->dispatch( $put );
$body = $response->get_data();
$this->assertEquals( $get_body['date'], $body['date'] );
$this->assertEquals( $get_body['date_gmt'], $body['date_gmt'] );
$this->assertEquals( strtotime( $get_body['date'] ), strtotime( $body['date'] ), 'The dates should be equal', 2 );
$this->assertEquals( strtotime( $get_body['date_gmt'] ), strtotime( $body['date_gmt'] ), 'The dates should be equal', 2 );
$this->assertNotEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
}

0 comments on commit 4b6a9f9

Please sign in to comment.
You can’t perform that action at this time.