diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index 36f54541b2..f059590ac1 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -193,7 +193,7 @@ require_once ABSPATH . '/wp-settings.php'; // Delete any default posts & related data. _delete_all_posts(); -if ( version_compare( tests_get_phpunit_version(), '7.0', '>=' ) ) { +if ( version_compare( tests_get_phpunit_version(), '7.5', '>=' ) ) { require __DIR__ . '/phpunit7/testcase.php'; } else { require __DIR__ . '/testcase.php'; diff --git a/tests/phpunit/includes/phpunit6/compat.php b/tests/phpunit/includes/phpunit6/compat.php index 61aa6048e9..dcc99e9a76 100644 --- a/tests/phpunit/includes/phpunit6/compat.php +++ b/tests/phpunit/includes/phpunit6/compat.php @@ -11,7 +11,6 @@ if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner class_alias( 'PHPUnit\Framework\Test', 'PHPUnit_Framework_Test' ); class_alias( 'PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning' ); class_alias( 'PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError' ); - class_alias( 'PHPUnit\Framework\Constraint\IsEqual', 'PHPUnit_Framework_Constraint_IsEqual' ); class_alias( 'PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite' ); class_alias( 'PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener' ); class_alias( 'PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState' ); diff --git a/tests/phpunit/includes/phpunit7/testcase.php b/tests/phpunit/includes/phpunit7/testcase.php index 9a8ddc12de..84ddbd5be1 100644 --- a/tests/phpunit/includes/phpunit7/testcase.php +++ b/tests/phpunit/includes/phpunit7/testcase.php @@ -11,30 +11,4 @@ require_once dirname( __DIR__ ) . '/abstract-testcase.php'; * * All WordPress unit tests should inherit from this class. */ -class WP_UnitTestCase extends WP_UnitTestCase_Base { - - /** - * Asserts that two variables are equal (with delta). - * - * This method has been backported from a more recent PHPUnit version, - * as tests running on PHP 5.6 use PHPUnit 5.7.x. - * - * @since 5.6.0 - * - * @param mixed $expected First value to compare. - * @param mixed $actual Second value to compare. - * @param float $delta Allowed numerical distance between two values to consider them equal. - * @param string $message Optional. Message to display when the assertion fails. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - */ - public static function assertEqualsWithDelta( $expected, $actual, float $delta, string $message = '' ): void { - $constraint = new PHPUnit\Framework\Constraint\IsEqual( - $expected, - $delta - ); - - static::assertThat( $actual, $constraint, $message ); - } -} +class WP_UnitTestCase extends WP_UnitTestCase_Base {} diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 6d90d6c0c5..019606c686 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -30,11 +30,6 @@ class WP_UnitTestCase extends WP_UnitTestCase_Base { * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ public static function assertEqualsWithDelta( $expected, $actual, $delta, $message = '' ) { - $constraint = new PHPUnit_Framework_Constraint_IsEqual( - $expected, - $delta - ); - - static::assertThat( $actual, $constraint, $message ); + static::assertEquals( $expected, $actual, $message, $delta ); } }