assertNan()
assertNan(mixed $variable[, string $message = ''])
当 $variable
不是 NAN
时报告错误,错误讯息由 $message
指定。
- <?php
- use PHPUnit\Framework\TestCase;
- class NanTest extends TestCase
- {
- public function testFailure()
- {
- $this->assertNan(1);
- }
- }
- ?>
phpunit NanTest
- PHPUnit 6.5.0 by Sebastian Bergmann and contributors.
- F
- Time: 0 seconds, Memory: 5.00Mb
- There was 1 failure:
- 1) NanTest::testFailure
- Failed asserting that 1 is nan.
- /home/sb/NanTest.php:6
- FAILURES!
- Tests: 1, Assertions: 1, Failures: 1.