Skip to content

Commit

Permalink
minor #32886 [PhpUnitBridge] Add polyfill for methods assertNan, asse…
Browse files Browse the repository at this point in the history
…rtFinite and assertInfinite (jderusse)

This PR was merged into the 4.4 branch.

Discussion
----------

[PhpUnitBridge] Add polyfill for methods assertNan, assertFinite and assertInfinite

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32844
| License       | MIT
| Doc PR        | NA

Provide pollyfile for methods `assertFinite`, `assertInfinite` and `assertNan`

Commits
-------

3450c17 [PhpUnitBridge] Add polyfill for methods assertNan, assertFinite and assertInfinite
  • Loading branch information
nicolas-grekas committed Aug 3, 2019
2 parents 621c740 + 3450c17 commit b3cf2d4
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV5.php
Expand Up @@ -235,6 +235,54 @@ public static function assertIsIterable($actual, $message = '')
static::assertInternalType('iterable', $actual, $message);
}

/**
* @param string $message
*
* @return void
*/
public static function assertFinite($actual, $message = '')
{
if (\is_callable('parent::assertFinite')) {
parent::assertFinite($actual, $message);

return;
}
static::assertInternalType('float', $actual, $message);
static::assertTrue(is_finite($actual), $message ? $message : "Failed asserting that $actual is finite.");
}

/**
* @param string $message
*
* @return void
*/
public static function assertInfinite($actual, $message = '')
{
if (\is_callable('parent::assertInfinite')) {
parent::assertInfinite($actual, $message);

return;
}
static::assertInternalType('float', $actual, $message);
static::assertTrue(is_infinite($actual), $message ? $message : "Failed asserting that $actual is infinite.");
}

/**
* @param string $message
*
* @return void
*/
public static function assertNan($actual, $message = '')
{
if (\is_callable('parent::assertNan')) {
parent::assertNan($actual, $message);

return;
}
static::assertInternalType('float', $actual, $message);
static::assertTrue(is_nan($actual), $message ? $message : "Failed asserting that $actual is nan.");
}

/**
* @param string $exception
*
Expand Down

0 comments on commit b3cf2d4

Please sign in to comment.