Make WordPress Core


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

    r48937 r48952  
    441441        // Now some values around.
    442442        $hr = wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb );
    443         $this->assertEquals( 1.50000095367, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 );
     443        $this->assertEqualsWithDelta( 1.50000095367, (float) str_replace( ',', '.', $hr ), 0.0001, 'The values should be equal' );
    444444
    445445        $hr = wp_convert_bytes_to_hr( $tb - $mb - $kb );
    446         $this->assertEquals( 1023.99902248, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 );
     446        $this->assertEqualsWithDelta( 1023.99902248, (float) str_replace( ',', '.', $hr ), 0.0001, 'The values should be equal' );
    447447
    448448        $hr = wp_convert_bytes_to_hr( $gb + $gb / 2 + $mb );
    449         $this->assertEquals( 1.5009765625, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 );
     449        $this->assertEqualsWithDelta( 1.5009765625, (float) str_replace( ',', '.', $hr ), 0.0001, 'The values should be equal' );
    450450
    451451        $hr = wp_convert_bytes_to_hr( $gb - $mb - $kb );
    452         $this->assertEquals( 1022.99902344, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 );
     452        $this->assertEqualsWithDelta( 1022.99902344, (float) str_replace( ',', '.', $hr ), 0.0001, 'The values should be equal' );
    453453
    454454        // Edge.
Note: See TracChangeset for help on using the changeset viewer.