mageekguy\atoum\asserters\variable::isNull PHP Method

isNull() public method

public isNull ( $failMessage = null )
    public function isNull($failMessage = null)
    {
        if ($this->valueIsSet()->value === null) {
            $this->pass();
        } else {
            $this->fail($failMessage ?: $this->_('%s is not null', $this));
        }
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 public function testIsNull()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->boolean($asserter->wasSet())->isFalse()->exception(function () use($asserter) {
         $asserter->isNull(rand(-PHP_INT_MAX, PHP_INT_MAX));
     })->isInstanceOf('logicException')->hasMessage('Value is undefined')->if($asserter->setWith(null))->then->object($asserter->isNull())->isIdenticalTo($asserter)->if($asserter->setWith(''))->then->exception(function () use($asserter) {
         $asserter->isNull();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not null'), $asserter))->if($asserter->setWith(uniqid()))->then->exception(function () use($asserter) {
         $asserter->isNull();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not null'), $asserter))->if($asserter->setWith(0))->then->exception(function () use($asserter) {
         $asserter->isNull();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not null'), $asserter))->if($asserter->setWith(false))->then->exception(function () use($asserter) {
         $asserter->isNull();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not null'), $asserter));
 }