mageekguy\atoum\asserters\exception::hasMessage PHP Method

hasMessage() public method

public hasMessage ( $message, $failMessage = null )
    public function hasMessage($message, $failMessage = null)
    {
        if ($this->valueIsSet()->value->getMessage() == (string) $message) {
            $this->pass();
        } else {
            $this->fail($failMessage ?: $this->_('message \'%s\' is not identical to \'%s\'', $this->value->getMessage(), $message));
        }
        return $this;
    }

Usage Example

コード例 #1
0
ファイル: exception.php プロジェクト: andrewolobo/mpTracker
 public function testHasMessage()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->boolean($asserter->wasSet())->isFalse()->exception(function () use($asserter) {
         $asserter->hasMessage(uniqid());
     })->isInstanceOf('logicException')->hasMessage('Exception is undefined')->if($asserter->setWith(new atoum\exceptions\runtime($message = uniqid())))->then->exception(function () use($asserter, &$otherMessage) {
         $asserter->hasMessage($otherMessage = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('message \'%s\' is not identical to \'%s\''), $message, $otherMessage))->object($asserter->hasMessage($message))->isIdenticalTo($asserter);
 }