assertNull()
assertNull(mixed $variable[, string $message = ''])
Reports an error identified by $message
if $variable
is not null
.
assertNotNull()
is the inverse of this assertion and takes the same arguments.
Example A.39: Usage of assertNull()
<?php use PHPUnit\Framework\TestCase; class NullTest extends TestCase { public function testFailure() { $this->assertNull('foo'); } } ?>
phpunit NotNullTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time: 0 seconds, Memory: 5.00Mb There was 1 failure: 1) NullTest::testFailure Failed asserting that 'foo' is null. /home/sb/NotNullTest.php:6 FAILURES! Tests: 1, Assertions: 1, Failures: 1.
Please login to continue.