mageekguy\atoum\asserters\exception::hasNestedException PHP 메소드

hasNestedException() 공개 메소드

public hasNestedException ( exception $exception = null, $failMessage = null )
$exception exception
    public function hasNestedException(\exception $exception = null, $failMessage = null)
    {
        $nestedException = $this->valueIsSet()->value->getPrevious();
        if ($exception === null && $nestedException !== null || $exception !== null && $nestedException == $exception) {
            $this->pass();
        } else {
            $this->fail($failMessage ?: ($exception === null ? $this->_('exception does not contain any nested exception') : $this->_('exception does not contain this nested exception')));
        }
        return $this;
    }

Usage Example

예제 #1
0
 public function testHasNestedException()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->boolean($asserter->wasSet())->isFalse()->exception(function () use($asserter) {
         $asserter->hasNestedException();
     })->isInstanceOf('logicException')->hasMessage('Exception is undefined')->if($asserter->setWith(new atoum\exceptions\runtime('', 0)))->then->exception(function () use($asserter) {
         $asserter->hasNestedException();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage($generator->getLocale()->_('exception does not contain any nested exception'))->exception(function () use($asserter) {
         $asserter->hasNestedException(new \exception());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage($generator->getLocale()->_('exception does not contain this nested exception'))->if($asserter->setWith(new atoum\exceptions\runtime('', 0, $nestedException = new \exception())))->then->object($asserter->hasNestedException())->isIdenticalTo($asserter)->object($asserter->hasNestedException($nestedException))->isIdenticalTo($asserter)->exception(function () use($asserter) {
         $asserter->hasNestedException(new \exception());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage($generator->getLocale()->_('exception does not contain this nested exception'));
 }