Make WordPress Core

Changeset 46280


Ignore:
Timestamp:
09/23/2019 09:17:04 PM (5 years ago)
Author:
SergeyBiryukov
Message:

REST API: Use delta comparison for floating date tests added in [46252] to avoid race conditions.

See #39953.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r46272 r46280  
    44144414    }
    44154415
     4416    /**
     4417     * @ticket 39953
     4418     */
    44164419    public function test_putting_same_publish_date_does_not_remove_floating_date() {
    44174420
     
    44414444        $body     = $response->get_data();
    44424445
    4443         $this->assertEquals( $get_body['date'], $body['date'] );
    4444         $this->assertEquals( $get_body['date_gmt'], $body['date_gmt'] );
     4446        $this->assertEquals( strtotime( $get_body['date'] ), strtotime( $body['date'] ), 'The dates should be equal', 2 );
     4447        $this->assertEquals( strtotime( $get_body['date_gmt'] ), strtotime( $body['date_gmt'] ), 'The dates should be equal', 2 );
    44454448
    44464449        $this->assertEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
    44474450    }
    44484451
     4452    /**
     4453     * @ticket 39953
     4454     */
    44494455    public function test_putting_different_publish_date_removes_floating_date() {
    44504456
     
    44824488        $body     = $response->get_data();
    44834489
    4484         $this->assertEquals( mysql_to_rfc3339( $new_time ), $body['date'] );
     4490        $this->assertEquals( strtotime( mysql_to_rfc3339( $new_time ) ), strtotime( $body['date'] ), 'The dates should be equal', 2 );
    44854491
    44864492        $this->assertNotEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
    44874493    }
    44884494
     4495    /**
     4496     * @ticket 39953
     4497     */
    44894498    public function test_publishing_post_with_same_date_removes_floating_date() {
    44904499
     
    45214530        $body     = $response->get_data();
    45224531
    4523         $this->assertEquals( $get_body['date'], $body['date'] );
    4524         $this->assertEquals( $get_body['date_gmt'], $body['date_gmt'] );
     4532        $this->assertEquals( strtotime( $get_body['date'] ), strtotime( $body['date'] ), 'The dates should be equal', 2 );
     4533        $this->assertEquals( strtotime( $get_body['date_gmt'] ), strtotime( $body['date_gmt'] ), 'The dates should be equal', 2 );
    45254534
    45264535        $this->assertNotEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
Note: See TracChangeset for help on using the changeset viewer.