Make WordPress Core


Ignore:
Timestamp:
09/07/2020 03:12:17 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Tests: Add a polyfill for assertEqualsWithDelta() to WP_UnitTestCase and use it where appropriate.

assertEqualsWithDelta() was added in PHPUnit 7.5, while WordPress still supports PHPUnit 5.4.x as the minimum version.

See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/site.php

    r48939 r48952  
    410410
    411411                        // 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 );
     412                        $this->assertEqualsWithDelta( $current_time, strtotime( $blog->last_updated ), 2, 'The dates should be equal' );
    413413                }
    414414
    … …  
    17931793
    17941794                        $site = get_site( $site_id );
    1795                         $this->assertEquals( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
    1796                         $this->assertEquals( strtotime( $first_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
     1795                        $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' );
     1796                        $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->last_updated ), 2, 'The dates should be equal' );
    17971797
    17981798                        $second_date = current_time( 'mysql', true );
    … …  
    18011801
    18021802                        $site = get_site( $site_id );
    1803                         $this->assertEquals( strtotime( $first_date ), strtotime( $site->registered ), 'The dates should be equal', 2 );
    1804                         $this->assertEquals( strtotime( $second_date ), strtotime( $site->last_updated ), 'The dates should be equal', 2 );
     1803                        $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' );
     1804                        $this->assertEqualsWithDelta( strtotime( $second_date ), strtotime( $site->last_updated ), 2, 'The dates should be equal' );
    18051805                }
    18061806
Note: See TracChangeset for help on using the changeset viewer.