c31a551273
* Replace the `Match` interface with `ParametersMatch`, to avoid parse errors due to `match` being a reserved keyword in PHP 8. * Replace `ReflectionParameter::getClass()` usage, which is deprecated in PHP 8. This allows tests relying on the `getMockForAbstractClass()` and `getMockBuilder()` methods to run again on PHP 8. When the test suite is updated for compatibility with PHPUnit 9.x, these overrides can be removed. Follow-up to [48972]. See #50913, #50902. git-svn-id: https://develop.svn.wordpress.org/trunk@49037 602fd350-edb4-49c9-b593-d223f7449a82
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
require_once dirname( __DIR__ ) . '/abstract-testcase.php';
|
|
|
|
/**
|
|
* Defines a basic fixture to run multiple tests.
|
|
*
|
|
* Resets the state of the WordPress installation before and after every test.
|
|
*
|
|
* Includes utility functions and assertions useful for testing WordPress.
|
|
*
|
|
* 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 );
|
|
}
|
|
}
|