Make WordPress Core


Ignore:
Timestamp:
09/07/2020 03:12:17 AM (3 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/formatting/date.php

    r48937 r48952  
    8686        $local = 'now';
    8787        $gmt   = gmdate( 'Y-m-d H:i:s' );
    88         $this->assertEquals( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 'The dates should be equal', 2 );
     88        $this->assertEqualsWithDelta( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 2, 'The dates should be equal' );
    8989    }
    9090
     
    9595        $local = 'now';
    9696        $gmt   = gmdate( 'Y-m-d H:i:s' );
    97         $this->assertEquals( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 'The dates should be equal', 2 );
     97        $this->assertEqualsWithDelta( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 2, 'The dates should be equal' );
    9898    }
    9999
Note: See TracChangeset for help on using the changeset viewer.