mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-25 07:44:34 +00:00
Tests: Minimize the chances of signature conflicts for assertEqualsWithDelta().
The PHPUnit 7.5+ method `assertEqualsWithDelta()` was polyfilled for PHPUnit < 7.5, but also overloaded for PHPUnit 7.5 itself, which was not necessary and created a higher chance of signature conflicts, especially when the WP test suite is used as a basis for integration tests with plugins/themes. This change removes the unnecessary overloading for PHPUnit 7.5+ and simplifies the overloaded method for PHPUnit < 7.5, including removing the `IsEqual()` class alias declaration, no longer needed. Follow-up to [48952]. Props jrf. See #52625. git-svn-id: https://develop.svn.wordpress.org/trunk@50986 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user