Skip to content

Commit 792c658

Browse files
minor #32886 [PhpUnitBridge] Add polyfill for methods assertNan, assertFinite 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 ------- 3450c1705e [PhpUnitBridge] Add polyfill for methods assertNan, assertFinite and assertInfinite
2 parents 1f2dd3a + 3bc5633 commit 792c658

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Legacy/ForwardCompatTestTraitForV5.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,54 @@ public static function assertIsIterable($actual, $message = '')
235235
static::assertInternalType('iterable', $actual, $message);
236236
}
237237

238+
/**
239+
* @param string $message
240+
*
241+
* @return void
242+
*/
243+
public static function assertFinite($actual, $message = '')
244+
{
245+
if (\is_callable('parent::assertFinite')) {
246+
parent::assertFinite($actual, $message);
247+
248+
return;
249+
}
250+
static::assertInternalType('float', $actual, $message);
251+
static::assertTrue(is_finite($actual), $message ? $message : "Failed asserting that $actual is finite.");
252+
}
253+
254+
/**
255+
* @param string $message
256+
*
257+
* @return void
258+
*/
259+
public static function assertInfinite($actual, $message = '')
260+
{
261+
if (\is_callable('parent::assertInfinite')) {
262+
parent::assertInfinite($actual, $message);
263+
264+
return;
265+
}
266+
static::assertInternalType('float', $actual, $message);
267+
static::assertTrue(is_infinite($actual), $message ? $message : "Failed asserting that $actual is infinite.");
268+
}
269+
270+
/**
271+
* @param string $message
272+
*
273+
* @return void
274+
*/
275+
public static function assertNan($actual, $message = '')
276+
{
277+
if (\is_callable('parent::assertNan')) {
278+
parent::assertNan($actual, $message);
279+
280+
return;
281+
}
282+
static::assertInternalType('float', $actual, $message);
283+
static::assertTrue(is_nan($actual), $message ? $message : "Failed asserting that $actual is nan.");
284+
}
285+
238286
/**
239287
* @param string $exception
240288
*

0 commit comments

Comments
 (0)