How to use hasMessage method of exception class

Best Atoum code snippet using exception.hasMessage

mock.php

Source:mock.php Github

copy

Full Screen

...82 ->exception(function () use ($asserter, & $mock) {83 $asserter->setWith($mock = uniqid());84 })85 ->isInstanceOf(atoum\asserter\exception::class)86 ->hasMessage($notMock)87 ->mock($locale)->call('_')->withArguments('%s is not a mock', $type)->once88 ->mock($analyzer)->call('getTypeOf')->withArguments($mock)->once89 ->object($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\mock()))->isIdenticalTo($asserter)90 ->object($asserter->getAdapter())->isIdenticalTo($mock->getMockController())91 ;92 }93 public function testWasCalled()94 {95 $this96 ->if($asserter = $this->newTestedInstance)97 ->then98 ->exception(function () use ($asserter) {99 $asserter->wasCalled();100 })101 ->isInstanceOf(atoum\exceptions\logic::class)102 ->hasMessage('Mock is undefined')103 ->if(104 $asserter105 ->setWith($mock = new \mock\foo($controller = new \mock\atoum\mock\controller()))106 ->setLocale($locale = new \mock\atoum\locale()),107 $this->calling($locale)->_ = $wasNotCalled = uniqid(),108 $this->calling($controller)->getCallsNumber = 0,109 $this->calling($controller)->getMockClass = $mockClass = uniqid()110 )111 ->then112 ->exception(function () use ($asserter) {113 $asserter->wasCalled();114 })115 ->isInstanceOf(atoum\asserter\exception::class)116 ->hasMessage($wasNotCalled)117 ->mock($locale)->call('_')->withArguments('%s is not called', $mockClass)->once118 ->exception(function () use ($asserter) {119 $asserter->wasCalled;120 })121 ->isInstanceOf(atoum\asserter\exception::class)122 ->hasMessage($wasNotCalled)123 ->mock($locale)->call('_')->withArguments('%s is not called', $mockClass)->twice124 ->exception(function () use ($asserter, & $failMessage) {125 $asserter->wasCalled($failMessage = uniqid());126 })127 ->isInstanceOf(atoum\asserter\exception::class)128 ->hasMessage($failMessage)129 ->if($this->calling($controller)->getCallsNumber = rand(1, PHP_INT_MAX))130 ->then131 ->object($asserter->wasCalled())->isIdenticalTo($asserter)132 ->object($asserter->wasCalled)->isIdenticalTo($asserter)133 ;134 }135 public function testWasNotCalled()136 {137 $this138 ->if($asserter = $this->newTestedInstance)139 ->then140 ->exception(function () use ($asserter) {141 $asserter->wasNotCalled();142 })143 ->isInstanceOf(atoum\exceptions\logic::class)144 ->hasMessage('Mock is undefined')145 ->if(146 $asserter147 ->setWith($mock = new \mock\foo($controller = new \mock\atoum\mock\controller()))148 ->setLocale($locale = new \mock\atoum\locale()),149 $this->calling($locale)->_ = $wasCalled = uniqid(),150 $this->calling($controller)->getCallsNumber = rand(1, PHP_INT_MAX),151 $this->calling($controller)->getMockClass = $mockClass = uniqid()152 )153 ->then154 ->exception(function () use ($asserter) {155 $asserter->wasNotCalled();156 })157 ->isInstanceOf(atoum\asserter\exception::class)158 ->hasMessage($wasCalled)159 ->mock($locale)->call('_')->withArguments('%s is called', $mockClass)->once160 ->exception(function () use ($asserter) {161 $asserter->wasNotCalled;162 })163 ->isInstanceOf(atoum\asserter\exception::class)164 ->hasMessage($wasCalled)165 ->mock($locale)->call('_')->withArguments('%s is called', $mockClass)->twice166 ->exception(function () use ($asserter, & $failMessage) {167 $asserter->wasNotCalled($failMessage = uniqid());168 })169 ->isInstanceOf(atoum\asserter\exception::class)170 ->hasMessage($failMessage)171 ->if($this->calling($controller)->getCallsNumber = 0)172 ->then173 ->object($asserter->wasNotCalled())->isIdenticalTo($asserter)174 ->object($asserter->wasNotCalled)->isIdenticalTo($asserter)175 ;176 }177 public function testCall()178 {179 $this180 ->given($asserter = $this->newTestedInstance)181 ->then182 ->exception(function () use ($asserter) {183 $asserter->call(uniqid());184 })185 ->isInstanceOf(atoum\exceptions\logic::class)186 ->hasMessage('Mock is undefined')187 ->given(188 $asserter->setManager($manager = new \mock\atoum\asserters\adapter\call\manager()),189 $mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()),190 $this->calling($mockController)->getMockClass = $mockClass = uniqid()191 )192 ->if($asserter->setWith($mock))193 ->then194 ->object($asserter->call($function = uniqid()))->isIdenticalTo($asserter)195 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)196 ->integer($asserter->getLastAssertionLine())->isEqualTo(__LINE__ - 2)197 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mockClass)))198 ->array($asserter->getBefore())->isEmpty199 ->array($asserter->getAfter())->isEmpty200 ->mock($manager)->call('add')->withArguments($asserter)->once201 ->object($asserter->call($otherFunction = uniqid()))->isIdenticalTo($asserter)202 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)203 ->integer($asserter->getLastAssertionLine())->isEqualTo(__LINE__ - 2)204 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($otherFunction, null, new decorators\addClass($mockClass)))205 ->array($asserter->getBefore())->isEmpty206 ->array($asserter->getAfter())->isEmpty207 ->mock($manager)->call('add')->withArguments($asserter)->twice208 ;209 }210 public function testReceive()211 {212 $this213 ->given($asserter = $this->newTestedInstance)214 ->then215 ->exception(function () use ($asserter) {216 $asserter->receive(uniqid());217 })218 ->isInstanceOf(atoum\exceptions\logic::class)219 ->hasMessage('Mock is undefined')220 ->given(221 $asserter->setManager($manager = new \mock\atoum\asserters\adapter\call\manager()),222 $mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()),223 $this->calling($mockController)->getMockClass = $mockClass = uniqid()224 )225 ->if($asserter->setWith($mock))226 ->then227 ->object($asserter->receive($function = uniqid()))->isIdenticalTo($asserter)228 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)229 ->integer($asserter->getLastAssertionLine())->isEqualTo(__LINE__ - 2)230 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mockClass)))231 ->array($asserter->getBefore())->isEmpty232 ->array($asserter->getAfter())->isEmpty233 ->mock($manager)->receive('add')->withArguments($asserter)->once234 ->object($asserter->receive($otherFunction = uniqid()))->isIdenticalTo($asserter)235 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)236 ->integer($asserter->getLastAssertionLine())->isEqualTo(__LINE__ - 2)237 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($otherFunction, null, new decorators\addClass($mockClass)))238 ->array($asserter->getBefore())->isEmpty239 ->array($asserter->getAfter())->isEmpty240 ->mock($manager)->receive('add')->withArguments($asserter)->twice241 ;242 }243 public function testWithArguments()244 {245 $this246 ->given($asserter = $this->newTestedInstance)247 ->then248 ->exception(function () use ($asserter) {249 $asserter->withArguments();250 })251 ->isInstanceOf(atoum\exceptions\logic::class)252 ->hasMessage('Mock is undefined')253 ->given(254 $mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()),255 $this->calling($mockController)->getMockClass = $mockClass = uniqid()256 )257 ->if($asserter->setWith($mock))258 ->then259 ->exception(function () use ($asserter) {260 $asserter->withArguments();261 })262 ->isInstanceOf(atoum\exceptions\logic::class)263 ->hasMessage('Call is undefined')264 ->if(265 $asserter->setManager($manager = new \mock\atoum\asserters\adapter\call\manager()),266 $asserter->call($function = uniqid())267 )268 ->then269 ->object($asserter->withArguments())->isIdenticalTo($asserter)270 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)271 ->integer($asserter->getLastAssertionLine())->isEqualTo(__LINE__ - 2)272 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, [], new decorators\addClass($mockClass)))273 ->array($asserter->getBefore())->isEmpty274 ->array($asserter->getAfter())->isEmpty275 ->mock($manager)->call('add')->withArguments($asserter)->once276 ->object($asserter->withArguments($arg1 = uniqid()))->isIdenticalTo($asserter)277 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)278 ->integer($asserter->getLastAssertionLine())->isEqualTo(__LINE__ - 2)279 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, [$arg1], new decorators\addClass($mockClass)))280 ->array($asserter->getBefore())->isEmpty281 ->array($asserter->getAfter())->isEmpty282 ->mock($manager)->call('add')->withArguments($asserter)->once283 ->object($asserter->withArguments($arg1 = uniqid(), $arg2 = uniqid()))->isIdenticalTo($asserter)284 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)285 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)286 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, [$arg1, $arg2], new decorators\addClass($mockClass)))287 ->array($asserter->getBefore())->isEmpty288 ->array($asserter->getAfter())->isEmpty289 ->mock($manager)->call('add')->withArguments($asserter)->once290 ;291 }292 public function testWithAtLeastArguments()293 {294 $this295 ->given($asserter = $this->newTestedInstance)296 ->then297 ->exception(function () use ($asserter) {298 $asserter->withAtLeastArguments([uniqid()]);299 })300 ->isInstanceOf(atoum\exceptions\logic::class)301 ->hasMessage('Mock is undefined')302 ->given(303 $mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()),304 $this->calling($mockController)->getMockClass = $mockClass = uniqid()305 )306 ->if($asserter->setWith($mock))307 ->then308 ->exception(function () use ($asserter) {309 $asserter->withAtLeastArguments([uniqid()]);310 })311 ->isInstanceOf(atoum\exceptions\logic::class)312 ->hasMessage('Call is undefined')313 ->if(314 $asserter->setManager($manager = new \mock\atoum\asserters\adapter\call\manager()),315 $asserter->call($function = uniqid())316 )317 ->then318 ->object($asserter->withAtLeastArguments($arguments = [1 => uniqid()]))->isIdenticalTo($asserter)319 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)320 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)321 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, $arguments, new decorators\addClass($mockClass)))322 ->array($asserter->getBefore())->isEmpty323 ->array($asserter->getAfter())->isEmpty324 ->mock($manager)->call('add')->withArguments($asserter)->once325 ->object($asserter->disableEvaluationChecking()->withAtLeastArguments($arguments = [2 => uniqid(), 5 => uniqid()]))->isIdenticalTo($asserter)326 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)327 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)328 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, $arguments, new decorators\addClass($mockClass)))329 ->array($asserter->getBefore())->isEmpty330 ->array($asserter->getAfter())->isEmpty331 ->mock($manager)->call('add')->withArguments($asserter)->once332 ;333 }334 public function testWithAnyArguments()335 {336 $this337 ->given($asserter = $this->newTestedInstance)338 ->then339 ->exception(function () use ($asserter) {340 $asserter->withAnyArguments();341 })342 ->isInstanceOf(atoum\exceptions\logic::class)343 ->hasMessage('Mock is undefined')344 ->exception(function () use ($asserter) {345 $asserter->withAnyArguments;346 })347 ->isInstanceOf(atoum\exceptions\logic::class)348 ->hasMessage('Mock is undefined')349 ->exception(function () use ($asserter) {350 $asserter->WITHaNYaRGUMENts;351 })352 ->isInstanceOf(atoum\exceptions\logic::class)353 ->hasMessage('Mock is undefined')354 ->given(355 $mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()),356 $this->calling($mockController)->getMockClass = $mockClass = uniqid()357 )358 ->if($asserter->setWith($mock))359 ->then360 ->exception(function () use ($asserter) {361 $asserter->withAnyArguments();362 })363 ->isInstanceOf(atoum\exceptions\logic::class)364 ->hasMessage('Call is undefined')365 ->exception(function () use ($asserter) {366 $asserter->withAnyArguments;367 })368 ->isInstanceOf(atoum\exceptions\logic::class)369 ->hasMessage('Call is undefined')370 ->exception(function () use ($asserter) {371 $asserter->wITHaNYArguments;372 })373 ->isInstanceOf(atoum\exceptions\logic::class)374 ->hasMessage('Call is undefined')375 ->if(376 $asserter->setManager($manager = new \mock\atoum\asserters\adapter\call\manager()),377 $asserter->call($function = uniqid())378 )379 ->then380 ->object($asserter->withAnyArguments())->isIdenticalTo($asserter)381 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)382 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)383 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mockClass)))384 ->array($asserter->getBefore())->isEmpty385 ->array($asserter->getAfter())->isEmpty386 ->mock($manager)->call('add')->withArguments($asserter)->once387 ->object($asserter->withAnyArguments)->isIdenticalTo($asserter)388 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)389 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)390 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mockClass)))391 ->array($asserter->getBefore())->isEmpty392 ->array($asserter->getAfter())->isEmpty393 ->mock($manager)->call('add')->withArguments($asserter)->once394 ->if($asserter->withArguments(uniqid()))395 ->then396 ->object($asserter->withAnyArguments())->isIdenticalTo($asserter)397 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)398 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)399 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mockClass)))400 ->array($asserter->getBefore())->isEmpty401 ->array($asserter->getAfter())->isEmpty402 ->mock($manager)->call('add')->withArguments($asserter)->once403 ->if($asserter->withArguments(uniqid()))404 ->then405 ->object($asserter->withAnyArguments)->isIdenticalTo($asserter)406 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)407 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)408 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mockClass)))409 ->array($asserter->getBefore())->isEmpty410 ->array($asserter->getAfter())->isEmpty411 ->mock($manager)->call('add')->withArguments($asserter)->once412 ;413 }414 public function testWithoutAnyArgument()415 {416 $this417 ->given($asserter = $this->newTestedInstance)418 ->then419 ->exception(function () use ($asserter) {420 $asserter->withoutAnyArgument();421 })422 ->isInstanceOf(atoum\exceptions\logic::class)423 ->hasMessage('Mock is undefined')424 ->exception(function () use ($asserter) {425 $asserter->withoutAnyArgument;426 })427 ->isInstanceOf(atoum\exceptions\logic::class)428 ->hasMessage('Mock is undefined')429 ->exception(function () use ($asserter) {430 $asserter->witHOUTaNYaRGument;431 })432 ->isInstanceOf(atoum\exceptions\logic::class)433 ->hasMessage('Mock is undefined')434 ->given(435 $mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()),436 $this->calling($mockController)->getMockClass = $mockClass = uniqid()437 )438 ->if($asserter->setWith($mock))439 ->then440 ->exception(function () use ($asserter) {441 $asserter->withoutAnyArgument();442 })443 ->isInstanceOf(atoum\exceptions\logic::class)444 ->hasMessage('Call is undefined')445 ->exception(function () use ($asserter) {446 $asserter->withoutAnyArgument;447 })448 ->isInstanceOf(atoum\exceptions\logic::class)449 ->hasMessage('Call is undefined')450 ->exception(function () use ($asserter) {451 $asserter->withoUTaNyArgumENT;452 })453 ->isInstanceOf(atoum\exceptions\logic::class)454 ->hasMessage('Call is undefined')455 ->if(456 $asserter->setManager($manager = new \mock\atoum\asserters\adapter\call\manager()),457 $asserter->call($function = uniqid())458 )459 ->then460 ->object($asserter->withoutAnyArgument())->isIdenticalTo($asserter)461 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)462 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)463 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, [], new decorators\addClass($mockClass)))464 ->array($asserter->getBefore())->isEmpty465 ->array($asserter->getAfter())->isEmpty466 ->mock($manager)->call('add')->withArguments($asserter)->once467 ->object($asserter->withoutAnyArgument)->isIdenticalTo($asserter)468 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)469 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)470 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, [], new decorators\addClass($mockClass)))471 ->array($asserter->getBefore())->isEmpty472 ->array($asserter->getAfter())->isEmpty473 ->mock($manager)->call('add')->withArguments($asserter)->once474 ->object($asserter->wITHOUTaNYaRGument)->isIdenticalTo($asserter)475 ->string($asserter->getLastAssertionFile())->isEqualTo(__FILE__)476 ->integer($asserter->getLastAssertionLine())->isEqualTo($line = __LINE__ - 2)477 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, [], new decorators\addClass($mockClass)))478 ->array($asserter->getBefore())->isEmpty479 ->array($asserter->getAfter())->isEmpty480 ->mock($manager)->call('add')->withArguments($asserter)->once481 ;482 }483 public function testNever()484 {485 $this486 ->given($asserter = $this->newTestedInstance)487 ->then488 ->exception(function () use ($asserter) {489 $asserter->never();490 })491 ->isInstanceOf(atoum\exceptions\logic::class)492 ->hasMessage('Mock is undefined')493 ->exception(function () use ($asserter) {494 $asserter->never;495 })496 ->isInstanceOf(atoum\exceptions\logic::class)497 ->hasMessage('Mock is undefined')498 ->exception(function () use ($asserter) {499 $asserter->NEVEr;500 })501 ->isInstanceOf(atoum\exceptions\logic::class)502 ->hasMessage('Mock is undefined')503 ->given($mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()))504 ->if($asserter->setWith($mock))505 ->then506 ->exception(function () use ($asserter) {507 $asserter->never();508 })509 ->isInstanceOf(atoum\exceptions\logic::class)510 ->hasMessage('Call is undefined')511 ->exception(function () use ($asserter) {512 $asserter->never;513 })514 ->isInstanceOf(atoum\exceptions\logic::class)515 ->hasMessage('Call is undefined')516 ->exception(function () use ($asserter) {517 $asserter->nEVER;518 })519 ->isInstanceOf(atoum\exceptions\logic::class)520 ->hasMessage('Call is undefined')521 ->if(522 $asserter523 ->call(uniqid())524 ->setCall($call = new \mock\atoum\test\adapter\call())525 ->setLocale($locale = new \mock\atoum\locale()),526 $this->calling($mockController)->getCalls = $calls = new \mock\atoum\test\adapter\calls(),527 $this->calling($calls)->count = $number = rand(1, PHP_INT_MAX),528 $this->calling($call)->__toString = $callAsString = uniqid(),529 $this->calling($locale)->__ = $notCalled = uniqid()530 )531 ->then532 ->exception(function () use ($asserter) {533 $asserter->never();534 })535 ->isInstanceOf(atoum\asserter\exception::class)536 ->hasMessage($notCalled)537 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 0)->once538 ->exception(function () use ($asserter, & $failMessage) {539 $asserter->once($failMessage = uniqid());540 })541 ->isInstanceOf(atoum\asserter\exception::class)542 ->hasMessage($failMessage)543 ->exception(function () use ($asserter) {544 $asserter->never;545 })546 ->isInstanceOf(atoum\asserter\exception::class)547 ->hasMessage($notCalled)548 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 0)->twice549 ->exception(function () use ($asserter) {550 $asserter->nEVER;551 })552 ->isInstanceOf(atoum\asserter\exception::class)553 ->hasMessage($notCalled)554 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 0)->thrice555 ->if($this->calling($calls)->count = 0)556 ->then557 ->object($this->testedInstance->never())->isTestedInstance558 ->object($this->testedInstance->never)->isTestedInstance559 ->object($this->testedInstance->nEVer)->isTestedInstance560 ;561 }562 public function testOnce()563 {564 $this565 ->given($asserter = $this->newTestedInstance)566 ->then567 ->exception(function () use ($asserter) {568 $asserter->once();569 })570 ->isInstanceOf(atoum\exceptions\logic::class)571 ->hasMessage('Mock is undefined')572 ->exception(function () use ($asserter) {573 $asserter->once;574 })575 ->isInstanceOf(atoum\exceptions\logic::class)576 ->hasMessage('Mock is undefined')577 ->exception(function () use ($asserter) {578 $asserter->oNCE;579 })580 ->isInstanceOf(atoum\exceptions\logic::class)581 ->hasMessage('Mock is undefined')582 ->given($mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()))583 ->if($asserter->setWith($mock))584 ->then585 ->exception(function () use ($asserter) {586 $asserter->once();587 })588 ->isInstanceOf(atoum\exceptions\logic::class)589 ->hasMessage('Call is undefined')590 ->exception(function () use ($asserter) {591 $asserter->once;592 })593 ->isInstanceOf(atoum\exceptions\logic::class)594 ->hasMessage('Call is undefined')595 ->exception(function () use ($asserter) {596 $asserter->oNCE;597 })598 ->isInstanceOf(atoum\exceptions\logic::class)599 ->hasMessage('Call is undefined')600 ->if(601 $asserter602 ->call(uniqid())603 ->setCall($call = new \mock\atoum\test\adapter\call())604 ->setLocale($locale = new \mock\atoum\locale()),605 $this->calling($mockController)->getCalls = $calls = new \mock\atoum\test\adapter\calls(),606 $this->calling($calls)->count = 0,607 $this->calling($call)->__toString = $callAsString = uniqid(),608 $this->calling($locale)->__ = $notCalled = uniqid()609 )610 ->then611 ->exception(function () use ($asserter) {612 $asserter->once();613 })614 ->isInstanceOf(atoum\asserter\exception::class)615 ->hasMessage($notCalled)616 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 1)->once617 ->exception(function () use ($asserter, & $failMessage) {618 $asserter->once($failMessage = uniqid());619 })620 ->isInstanceOf(atoum\asserter\exception::class)621 ->hasMessage($failMessage)622 ->exception(function () use ($asserter) {623 $asserter->once;624 })625 ->isInstanceOf(atoum\asserter\exception::class)626 ->hasMessage($notCalled)627 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 1)->twice628 ->exception(function () use ($asserter) {629 $asserter->oNCE;630 })631 ->isInstanceOf(atoum\asserter\exception::class)632 ->hasMessage($notCalled)633 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 1)->thrice634 ->if($this->calling($calls)->count = $number = rand(2, PHP_INT_MAX))635 ->then636 ->exception(function () use ($asserter) {637 $asserter->once();638 })639 ->isInstanceOf(atoum\asserter\exception::class)640 ->hasMessage($notCalled)641 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 1)->once642 ->exception(function () use ($asserter, & $failMessage) {643 $asserter->once($failMessage = uniqid());644 })645 ->isInstanceOf(atoum\asserter\exception::class)646 ->hasMessage($failMessage)647 ->exception(function () use ($asserter) {648 $asserter->once;649 })650 ->isInstanceOf(atoum\asserter\exception::class)651 ->hasMessage($notCalled)652 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 1)->twice653 ->exception(function () use ($asserter) {654 $asserter->oNCE;655 })656 ->isInstanceOf(atoum\asserter\exception::class)657 ->hasMessage($notCalled)658 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 1)->thrice659 ->if($this->calling($calls)->count = 1)660 ->then661 ->object($this->testedInstance->once())->isTestedInstance662 ->object($this->testedInstance->once)->isTestedInstance663 ->object($this->testedInstance->oNCE)->isTestedInstance664 ;665 }666 public function testTwice()667 {668 $this669 ->given($asserter = $this->newTestedInstance)670 ->then671 ->exception(function () use ($asserter) {672 $asserter->twice();673 })674 ->isInstanceOf(atoum\exceptions\logic::class)675 ->hasMessage('Mock is undefined')676 ->exception(function () use ($asserter) {677 $asserter->twice;678 })679 ->isInstanceOf(atoum\exceptions\logic::class)680 ->hasMessage('Mock is undefined')681 ->exception(function () use ($asserter) {682 $asserter->tWICe;683 })684 ->isInstanceOf(atoum\exceptions\logic::class)685 ->hasMessage('Mock is undefined')686 ->given($mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()))687 ->if($asserter->setWith($mock))688 ->then689 ->exception(function () use ($asserter) {690 $asserter->twice();691 })692 ->isInstanceOf(atoum\exceptions\logic::class)693 ->hasMessage('Call is undefined')694 ->exception(function () use ($asserter) {695 $asserter->twice;696 })697 ->isInstanceOf(atoum\exceptions\logic::class)698 ->hasMessage('Call is undefined')699 ->exception(function () use ($asserter) {700 $asserter->TWICe;701 })702 ->isInstanceOf(atoum\exceptions\logic::class)703 ->hasMessage('Call is undefined')704 ->if(705 $asserter706 ->call(uniqid())707 ->setCall($call = new \mock\atoum\test\adapter\call())708 ->setLocale($locale = new \mock\atoum\locale()),709 $this->calling($mockController)->getCalls = $calls = new \mock\atoum\test\adapter\calls(),710 $this->calling($calls)->count = 0,711 $this->calling($call)->__toString = $callAsString = uniqid(),712 $this->calling($locale)->__ = $notCalled = uniqid()713 )714 ->then715 ->exception(function () use ($asserter) {716 $asserter->twice();717 })718 ->isInstanceOf(atoum\asserter\exception::class)719 ->hasMessage($notCalled)720 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 2)->once721 ->exception(function () use ($asserter, & $failMessage) {722 $asserter->twice($failMessage = uniqid());723 })724 ->isInstanceOf(atoum\asserter\exception::class)725 ->hasMessage($failMessage)726 ->exception(function () use ($asserter) {727 $asserter->twice;728 })729 ->isInstanceOf(atoum\asserter\exception::class)730 ->hasMessage($notCalled)731 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 2)->twice732 ->exception(function () use ($asserter) {733 $asserter->tWiCE;734 })735 ->isInstanceOf(atoum\asserter\exception::class)736 ->hasMessage($notCalled)737 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 2)->thrice738 ->if($this->calling($calls)->count = $number = rand(3, PHP_INT_MAX))739 ->then740 ->exception(function () use ($asserter) {741 $asserter->twice();742 })743 ->isInstanceOf(atoum\asserter\exception::class)744 ->hasMessage($notCalled)745 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 2)->once746 ->exception(function () use ($asserter, & $failMessage) {747 $asserter->twice($failMessage = uniqid());748 })749 ->isInstanceOf(atoum\asserter\exception::class)750 ->hasMessage($failMessage)751 ->exception(function () use ($asserter) {752 $asserter->twice;753 })754 ->isInstanceOf(atoum\asserter\exception::class)755 ->hasMessage($notCalled)756 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 2)->twice757 ->exception(function () use ($asserter) {758 $asserter->tWICE;759 })760 ->isInstanceOf(atoum\asserter\exception::class)761 ->hasMessage($notCalled)762 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 2)->thrice763 ->if($this->calling($calls)->count = $number = 1)764 ->then765 ->exception(function () use ($asserter) {766 $asserter->twice();767 })768 ->isInstanceOf(atoum\asserter\exception::class)769 ->hasMessage($notCalled)770 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, 1, 2)->once771 ->exception(function () use ($asserter, & $failMessage) {772 $asserter->twice($failMessage = uniqid());773 })774 ->isInstanceOf(atoum\asserter\exception::class)775 ->hasMessage($failMessage)776 ->exception(function () use ($asserter) {777 $asserter->twice;778 })779 ->isInstanceOf(atoum\asserter\exception::class)780 ->hasMessage($notCalled)781 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, 1, 2)->twice782 ->exception(function () use ($asserter) {783 $asserter->tWICE;784 })785 ->isInstanceOf(atoum\asserter\exception::class)786 ->hasMessage($notCalled)787 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, 1, 2)->thrice788 ->if($this->calling($calls)->count = 2)789 ->then790 ->object($this->testedInstance->twice())->isTestedInstance791 ->object($this->testedInstance->twice)->isTestedInstance792 ->object($this->testedInstance->tWICE)->isTestedInstance793 ;794 }795 public function testThrice()796 {797 $this798 ->given($asserter = $this->newTestedInstance)799 ->then800 ->exception(function () use ($asserter) {801 $asserter->thrice();802 })803 ->isInstanceOf(atoum\exceptions\logic::class)804 ->hasMessage('Mock is undefined')805 ->exception(function () use ($asserter) {806 $asserter->thrice;807 })808 ->isInstanceOf(atoum\exceptions\logic::class)809 ->hasMessage('Mock is undefined')810 ->exception(function () use ($asserter) {811 $asserter->tHRICe;812 })813 ->isInstanceOf(atoum\exceptions\logic::class)814 ->hasMessage('Mock is undefined')815 ->given($mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()))816 ->if($asserter->setWith($mock))817 ->then818 ->exception(function () use ($asserter) {819 $asserter->thrice();820 })821 ->isInstanceOf(atoum\exceptions\logic::class)822 ->hasMessage('Call is undefined')823 ->exception(function () use ($asserter) {824 $asserter->thrice;825 })826 ->isInstanceOf(atoum\exceptions\logic::class)827 ->hasMessage('Call is undefined')828 ->exception(function () use ($asserter) {829 $asserter->THRICe;830 })831 ->isInstanceOf(atoum\exceptions\logic::class)832 ->hasMessage('Call is undefined')833 ->if(834 $asserter835 ->call(uniqid())836 ->setCall($call = new \mock\atoum\test\adapter\call())837 ->setLocale($locale = new \mock\atoum\locale()),838 $this->calling($mockController)->getCalls = $calls = new \mock\atoum\test\adapter\calls(),839 $this->calling($calls)->count = 0,840 $this->calling($call)->__toString = $callAsString = uniqid(),841 $this->calling($locale)->__ = $notCalled = uniqid()842 )843 ->then844 ->exception(function () use ($asserter) {845 $asserter->thrice();846 })847 ->isInstanceOf(atoum\asserter\exception::class)848 ->hasMessage($notCalled)849 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 3)->once850 ->exception(function () use ($asserter, & $failMessage) {851 $asserter->thrice($failMessage = uniqid());852 })853 ->isInstanceOf(atoum\asserter\exception::class)854 ->hasMessage($failMessage)855 ->exception(function () use ($asserter) {856 $asserter->thrice;857 })858 ->isInstanceOf(atoum\asserter\exception::class)859 ->hasMessage($notCalled)860 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 3)->twice861 ->exception(function () use ($asserter) {862 $asserter->tHRICE;863 })864 ->isInstanceOf(atoum\asserter\exception::class)865 ->hasMessage($notCalled)866 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, 3)->thrice867 ->if($this->calling($calls)->count = $number = rand(4, PHP_INT_MAX))868 ->then869 ->exception(function () use ($asserter) {870 $asserter->thrice();871 })872 ->isInstanceOf(atoum\asserter\exception::class)873 ->hasMessage($notCalled)874 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 3)->once875 ->exception(function () use ($asserter, & $failMessage) {876 $asserter->thrice($failMessage = uniqid());877 })878 ->isInstanceOf(atoum\asserter\exception::class)879 ->hasMessage($failMessage)880 ->exception(function () use ($asserter) {881 $asserter->thrice;882 })883 ->isInstanceOf(atoum\asserter\exception::class)884 ->hasMessage($notCalled)885 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 3)->twice886 ->exception(function () use ($asserter) {887 $asserter->tHRICe;888 })889 ->isInstanceOf(atoum\asserter\exception::class)890 ->hasMessage($notCalled)891 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 3)->thrice892 ->if($this->calling($calls)->count = $number = rand(1, 2))893 ->then894 ->exception(function () use ($asserter) {895 $asserter->thrice();896 })897 ->isInstanceOf(atoum\asserter\exception::class)898 ->hasMessage($notCalled)899 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 3)->once900 ->exception(function () use ($asserter, & $failMessage) {901 $asserter->thrice($failMessage = uniqid());902 })903 ->isInstanceOf(atoum\asserter\exception::class)904 ->hasMessage($failMessage)905 ->exception(function () use ($asserter) {906 $asserter->thrice;907 })908 ->isInstanceOf(atoum\asserter\exception::class)909 ->hasMessage($notCalled)910 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 3)->twice911 ->exception(function () use ($asserter) {912 $asserter->tHRICe;913 })914 ->isInstanceOf(atoum\asserter\exception::class)915 ->hasMessage($notCalled)916 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $number, $callAsString, $number, 3)->thrice917 ->if($this->calling($calls)->count = 3)918 ->then919 ->object($this->testedInstance->thrice())->isTestedInstance920 ->object($this->testedInstance->thrice)->isTestedInstance921 ->object($this->testedInstance->thRICE)->isTestedInstance922 ;923 }924 public function testAtLeastOnce()925 {926 $this927 ->given($asserter = $this->newTestedInstance)928 ->then929 ->exception(function () use ($asserter) {930 $asserter->atLeastOnce();931 })932 ->isInstanceOf(atoum\exceptions\logic::class)933 ->hasMessage('Mock is undefined')934 ->exception(function () use ($asserter) {935 $asserter->atLeastOnce;936 })937 ->isInstanceOf(atoum\exceptions\logic::class)938 ->hasMessage('Mock is undefined')939 ->exception(function () use ($asserter) {940 $asserter->ATlEASToNCe;941 })942 ->isInstanceOf(atoum\exceptions\logic::class)943 ->hasMessage('Mock is undefined')944 ->given($mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()))945 ->if($asserter->setWith($mock))946 ->then947 ->exception(function () use ($asserter) {948 $asserter->atLeastOnce();949 })950 ->isInstanceOf(atoum\exceptions\logic::class)951 ->hasMessage('Call is undefined')952 ->exception(function () use ($asserter) {953 $asserter->atLeastOnce;954 })955 ->isInstanceOf(atoum\exceptions\logic::class)956 ->hasMessage('Call is undefined')957 ->exception(function () use ($asserter) {958 $asserter->ATlEASToNCe;959 })960 ->isInstanceOf(atoum\exceptions\logic::class)961 ->hasMessage('Call is undefined')962 ->if(963 $asserter964 ->call(uniqid())965 ->setCall($call = new \mock\atoum\test\adapter\call())966 ->setLocale($locale = new \mock\atoum\locale()),967 $this->calling($mockController)->getCalls = $calls = new \mock\atoum\test\adapter\calls(),968 $this->calling($calls)->count = 0,969 $this->calling($call)->__toString = $callAsString = uniqid(),970 $this->calling($locale)->_ = $notCalled = uniqid()971 )972 ->then973 ->exception(function () use ($asserter) {974 $asserter->atLeastOnce();975 })976 ->isInstanceOf(atoum\asserter\exception::class)977 ->hasMessage($notCalled)978 ->mock($locale)->call('_')->withArguments('%s is called 0 time', $callAsString)->once979 ->exception(function () use ($asserter) {980 $asserter->atLeastOnce;981 })982 ->isInstanceOf(atoum\asserter\exception::class)983 ->hasMessage($notCalled)984 ->mock($locale)->call('_')->withArguments('%s is called 0 time', $callAsString)->twice985 ->exception(function () use ($asserter) {986 $asserter->atLEASToNCE;987 })988 ->isInstanceOf(atoum\asserter\exception::class)989 ->hasMessage($notCalled)990 ->mock($locale)->call('_')->withArguments('%s is called 0 time', $callAsString)->thrice991 ->exception(function () use ($asserter, & $failMessage) {992 $asserter->atLeastOnce($failMessage = uniqid());993 })994 ->isInstanceOf(atoum\asserter\exception::class)995 ->hasMessage($failMessage)996 ->if($this->calling($calls)->count = rand(1, PHP_INT_MAX))997 ->then998 ->object($this->testedInstance->atLeastOnce())->isTestedInstance999 ->object($this->testedInstance->atLeastOnce)->isTestedInstance1000 ->object($this->testedInstance->atLEASToNCe)->isTestedInstance1001 ;1002 }1003 public function testExactly()1004 {1005 $this1006 ->given($asserter = $this->newTestedInstance)1007 ->then1008 ->exception(function () use ($asserter) {1009 $asserter->exactly(rand(0, PHP_INT_MAX));1010 })1011 ->isInstanceOf(atoum\exceptions\logic::class)1012 ->hasMessage('Mock is undefined')1013 ->given($mock = new \mock\foo($mockController = new \mock\atoum\mock\controller()))1014 ->if($asserter->setWith($mock))1015 ->then1016 ->exception(function () use ($asserter) {1017 $asserter->exactly(rand(0, PHP_INT_MAX));1018 })1019 ->isInstanceOf(atoum\exceptions\logic::class)1020 ->hasMessage('Call is undefined')1021 ->if(1022 $asserter1023 ->call(uniqid())1024 ->setCall($call = new \mock\atoum\test\adapter\call())1025 ->setLocale($locale = new \mock\atoum\locale()),1026 $this->calling($mockController)->getCalls = $calls = new \mock\atoum\test\adapter\calls(),1027 $this->calling($calls)->count = 0,1028 $this->calling($call)->__toString = $callAsString = uniqid(),1029 $this->calling($locale)->__ = $notCalled = uniqid()1030 )1031 ->then1032 ->exception(function () use ($asserter, & $callNumber) {1033 $asserter->exactly($callNumber = rand(1, PHP_INT_MAX));1034 })1035 ->isInstanceOf(atoum\asserter\exception::class)1036 ->hasMessage($notCalled)1037 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', 0, $callAsString, 0, $callNumber)->once1038 ->exception(function () use ($asserter, & $callNumber, & $failMessage) {1039 $asserter->exactly($callNumber = rand(1, PHP_INT_MAX), $failMessage = uniqid());1040 })1041 ->isInstanceOf(atoum\asserter\exception::class)1042 ->hasMessage($failMessage)1043 ->object($this->testedInstance->exactly(0))->isTestedInstance1044 ->if(1045 $this->calling($calls)->count = $count = rand(1, PHP_INT_MAX),1046 $this->calling($mockController)->getCallsEqualTo = $callsEqualTo = new \mock\atoum\test\adapter\calls(),1047 $this->calling($callsEqualTo)->count = $count,1048 $this->calling($callsEqualTo)->__toString = $callsEqualToAsString = uniqid()1049 )1050 ->then1051 ->exception(function () use ($asserter) {1052 $asserter->exactly(0);1053 })1054 ->isInstanceOf(atoum\asserter\exception::class)1055 ->hasMessage($notCalled . PHP_EOL . $callsEqualToAsString)1056 ->mock($locale)->call('__')->withArguments('%s is called %d time instead of %d', '%s is called %d times instead of %d', $count, $callAsString, $count, 0)->once1057 ->exception(function () use ($asserter, & $failMessage) {1058 $asserter->exactly(0, $failMessage = uniqid());1059 })1060 ->isInstanceOf(atoum\asserter\exception::class)1061 ->hasMessage($failMessage)1062 ->object($this->testedInstance->exactly($count))->isTestedInstance1063 ;1064 }1065}...

Full Screen

Full Screen

variable.php

Source:variable.php Github

copy

Full Screen

...128 ->exception(function () use ($asserter) {129 $asserter->isEqualTo(rand(- PHP_INT_MAX, PHP_INT_MAX));130 })131 ->isInstanceOf(\logicException::class)132 ->hasMessage('Value is undefined')133 ->if($asserter->setWith($value = rand(- PHP_INT_MAX, PHP_INT_MAX)))134 ->then135 ->object($asserter->isEqualTo($value))->isIdenticalTo($asserter)136 ->object($asserter->isEqualTo((string) $value))->isIdenticalTo($asserter)137 ->object($asserter->{'=='}($value))->isIdenticalTo($asserter)138 ->if(139 $this->calling($locale)->_ = $localizedMessage = uniqid(),140 $this->calling($diff)->__toString = $diffValue = uniqid(),141 $this->calling($analyzer)->getTypeOf = $type = uniqid()142 )143 ->then144 ->exception(function () use ($asserter, & $notEqualValue) {145 $asserter->isEqualTo($notEqualValue = uniqid());146 })147 ->isInstanceOf(atoum\asserter\exception::class)148 ->hasMessage($localizedMessage . PHP_EOL . $diffValue)149 ->mock($locale)->call('_')->withArguments('%s is not equal to %s', $asserter, $type)->once150 ->mock($diff)151 ->call('setExpected')->withArguments($notEqualValue)->once152 ->call('setActual')->withArguments($value)->once153 ;154 }155 public function testIsNotEqualTo()156 {157 $this158 ->given(159 $asserter = $this->newTestedInstance160 ->setLocale($locale = new \mock\atoum\locale())161 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())162 )163 ->then164 ->exception(function () use ($asserter) {165 $asserter->isNotEqualTo(rand(- PHP_INT_MAX, PHP_INT_MAX));166 })167 ->isInstanceOf(\logicException::class)168 ->hasMessage('Value is undefined')169 ->if($asserter->setWith($value = uniqid()))170 ->then171 ->object($asserter->isNotEqualTo(uniqid()))->isIdenticalTo($asserter)172 ->object($asserter->{'!='}(uniqid()))->isIdenticalTo($asserter)173 ->if(174 $this->calling($locale)->_ = $localizedMessage = uniqid(),175 $this->calling($analyzer)->getTypeOf = $type = uniqid()176 )177 ->then178 ->exception(function () use ($asserter, $value) {179 $asserter->isNotEqualTo($value);180 })181 ->isInstanceOf(atoum\asserter\exception::class)182 ->hasMessage($localizedMessage)183 ->mock($locale)->call('_')->withArguments('%s is equal to %s', $asserter, $type)->once184 ;185 }186 public function testIsIdenticalTo()187 {188 $this189 ->given(190 $asserter = $this->newTestedInstance191 ->setLocale($locale = new \mock\atoum\locale())192 ->setDiff($diff = new \mock\atoum\tools\diffs\variable())193 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())194 )195 ->then196 ->exception(function () use ($asserter) {197 $asserter->isIdenticalTo(rand(- PHP_INT_MAX, PHP_INT_MAX));198 })199 ->isInstanceOf(\logicException::class)200 ->hasMessage('Value is undefined')201 ->if($asserter->setWith($value = rand(- PHP_INT_MAX, PHP_INT_MAX)))202 ->then203 ->object($asserter->isIdenticalTo($value))->isIdenticalTo($asserter)204 ->object($asserter->{'==='}($value))->isIdenticalTo($asserter)205 ->if(206 $this->calling($locale)->_ = $localizedMessage = uniqid(),207 $this->calling($diff)->__toString = $diffValue = uniqid(),208 $this->calling($analyzer)->getTypeOf = $type = uniqid()209 )210 ->then211 ->exception(function () use ($asserter, $value, & $notIdenticalValue) {212 $asserter->isIdenticalTo($notIdenticalValue = (string) $value);213 })214 ->isInstanceOf(atoum\asserter\exception::class)215 ->hasMessage($localizedMessage . PHP_EOL . $diffValue)216 ->mock($locale)->call('_')->withArguments('%s is not identical to %s', $asserter, $type)->once217 ->mock($diff)218 ->call('setExpected')->withArguments($notIdenticalValue)->once219 ->call('setActual')->withArguments($value)->once220 ->exception(function () use ($asserter, $value, & $notIdenticalValue) {221 $asserter->isIdenticalTo($notIdenticalValue = uniqid());222 })223 ->isInstanceOf(atoum\asserter\exception::class)224 ->hasMessage($localizedMessage . PHP_EOL . $diffValue)225 ->mock($locale)->call('_')->withArguments('%s is not identical to %s', $asserter, $type)->twice226 ->mock($diff)227 ->call('setExpected')->withArguments($notIdenticalValue)->once228 ->call('setActual')->withArguments($value)->twice229 ;230 }231 public function testIsNotIdenticalTo()232 {233 $this234 ->given(235 $asserter = $this->newTestedInstance236 ->setLocale($locale = new \mock\atoum\locale())237 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())238 )239 ->then240 ->exception(function () use ($asserter) {241 $asserter->isNotIdenticalTo(rand(- PHP_INT_MAX, PHP_INT_MAX));242 })243 ->isInstanceOf(\logicException::class)244 ->hasMessage('Value is undefined')245 ->if($asserter->setWith($value = rand(- PHP_INT_MAX, PHP_INT_MAX)))246 ->then247 ->object($asserter->isNotIdenticalTo((string) $value))->isIdenticalTo($asserter)248 ->object($asserter->isNotIdenticalTo(uniqid()))->isIdenticalTo($asserter)249 ->object($asserter->{'!=='}(uniqid()))->isIdenticalTo($asserter)250 ->if(251 $this->calling($locale)->_ = $localizedMessage = uniqid(),252 $this->calling($analyzer)->getTypeOf = $type = uniqid()253 )254 ->then255 ->exception(function () use ($asserter, $value) {256 $asserter->isNotIdenticalTo($value);257 })258 ->isInstanceOf(atoum\asserter\exception::class)259 ->hasMessage($localizedMessage)260 ->mock($locale)->call('_')->withArguments('%s is identical to %s', $asserter, $type)->once261 ;262 }263 public function testIsNull()264 {265 $this266 ->given(267 $asserter = $this->newTestedInstance268 ->setLocale($locale = new \mock\atoum\locale())269 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())270 )271 ->then272 ->exception(function () use ($asserter) {273 $asserter->isNull();274 })275 ->isInstanceOf(\logicException::class)276 ->hasMessage('Value is undefined')277 ->exception(function () use ($asserter) {278 $asserter->isNull;279 })280 ->isInstanceOf(\logicException::class)281 ->hasMessage('Value is undefined')282 ->if($asserter->setWith(null))283 ->then284 ->object($asserter->isNull())->isIdenticalTo($asserter)285 ->object($asserter->isNull)->isIdenticalTo($asserter)286 ->if(287 $asserter->setWith(uniqid()),288 $this->calling($locale)->_ = $localizedMessage = uniqid(),289 $this->calling($analyzer)->getTypeOf = $type = uniqid()290 )291 ->then292 ->exception(function () use ($asserter) {293 $asserter->isNull();294 })295 ->isInstanceOf(atoum\asserter\exception::class)296 ->hasMessage($localizedMessage)297 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->once298 ->exception(function () use ($asserter, & $failMessage) {299 $asserter->isNull($failMessage = uniqid());300 })301 ->isInstanceOf(atoum\asserter\exception::class)302 ->hasMessage($failMessage)303 ->exception(function () use ($asserter) {304 $asserter->isNull;305 })306 ->isInstanceOf(atoum\asserter\exception::class)307 ->hasMessage($localizedMessage)308 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->twice309 ->if(310 $asserter->setWith(''),311 $this->calling($locale)->_ = $localizedMessage = uniqid(),312 $this->calling($analyzer)->getTypeOf = $type = uniqid()313 )314 ->then315 ->exception(function () use ($asserter) {316 $asserter->isNull();317 })318 ->isInstanceOf(atoum\asserter\exception::class)319 ->hasMessage($localizedMessage)320 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->thrice()321 ->exception(function () use ($asserter, & $failMessage) {322 $asserter->isNull($failMessage = uniqid());323 })324 ->isInstanceOf(atoum\asserter\exception::class)325 ->hasMessage($failMessage)326 ->exception(function () use ($asserter) {327 $asserter->isNull;328 })329 ->isInstanceOf(atoum\asserter\exception::class)330 ->hasMessage($localizedMessage)331 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->exactly(4)332 ->if(333 $asserter->setWith(0),334 $this->calling($locale)->_ = $localizedMessage = uniqid(),335 $this->calling($analyzer)->getTypeOf = $type = uniqid()336 )337 ->then338 ->exception(function () use ($asserter) {339 $asserter->isNull();340 })341 ->isInstanceOf(atoum\asserter\exception::class)342 ->hasMessage($localizedMessage)343 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->exactly(5)344 ->exception(function () use ($asserter, & $failMessage) {345 $asserter->isNull($failMessage = uniqid());346 })347 ->isInstanceOf(atoum\asserter\exception::class)348 ->hasMessage($failMessage)349 ->exception(function () use ($asserter) {350 $asserter->isNull;351 })352 ->isInstanceOf(atoum\asserter\exception::class)353 ->hasMessage($localizedMessage)354 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->exactly(6)355 ->if(356 $asserter->setWith(false),357 $this->calling($locale)->_ = $localizedMessage = uniqid(),358 $this->calling($analyzer)->getTypeOf = $type = uniqid()359 )360 ->then361 ->exception(function () use ($asserter) {362 $asserter->isNull();363 })364 ->isInstanceOf(atoum\asserter\exception::class)365 ->hasMessage($localizedMessage)366 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->exactly(7)367 ->exception(function () use ($asserter, & $failMessage) {368 $asserter->isNull($failMessage = uniqid());369 })370 ->isInstanceOf(atoum\asserter\exception::class)371 ->hasMessage($failMessage)372 ->exception(function () use ($asserter) {373 $asserter->isNull;374 })375 ->isInstanceOf(atoum\asserter\exception::class)376 ->hasMessage($localizedMessage)377 ->mock($locale)->call('_')->withArguments('%s is not null', $asserter)->exactly(8)378 ;379 }380 public function testIsNotNull()381 {382 $this383 ->given(384 $asserter = $this->newTestedInstance385 ->setLocale($locale = new \mock\atoum\locale())386 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())387 )388 ->then389 ->exception(function () use ($asserter) {390 $asserter->isNotNull();391 })392 ->isInstanceOf(\logicException::class)393 ->hasMessage('Value is undefined')394 ->exception(function () use ($asserter) {395 $asserter->isNotNull;396 })397 ->isInstanceOf(\logicException::class)398 ->hasMessage('Value is undefined')399 ->if($asserter->setWith(uniqid()))400 ->then401 ->object($asserter->isNotNull())->isIdenticalTo($asserter)402 ->object($asserter->isNotNull)->isIdenticalTo($asserter)403 ->if(404 $asserter->setWith(null),405 $this->calling($locale)->_ = $localizedMessage = uniqid(),406 $this->calling($analyzer)->getTypeOf = $type = uniqid()407 )408 ->then409 ->exception(function () use ($asserter) {410 $asserter->isNotNull();411 })412 ->isInstanceOf(atoum\asserter\exception::class)413 ->hasMessage($localizedMessage)414 ->mock($locale)->call('_')->withArguments('%s is null', $asserter)->once415 ->exception(function () use ($asserter) {416 $asserter->isNotNull;417 })418 ->isInstanceOf(atoum\asserter\exception::class)419 ->hasMessage($localizedMessage)420 ->mock($locale)->call('_')->withArguments('%s is null', $asserter)->twice421 ->exception(function () use ($asserter, & $failMessage) {422 $asserter->isNotNull($failMessage = uniqid());423 })424 ->isInstanceOf(atoum\asserter\exception::class)425 ->hasMessage($failMessage)426 ;427 }428 public function testIsReferenceTo()429 {430 $this431 ->given(432 $asserter = $this->newTestedInstance433 ->setLocale($locale = new \mock\atoum\locale())434 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())435 )436 ->then437 ->exception(function () use ($asserter) {438 $value = uniqid();439 $asserter->isReferenceTo($value);440 })441 ->isInstanceOf(\logicException::class)442 ->hasMessage('Value is undefined')443 ->if($asserter->setWith($value = uniqid()))444 ->then445 ->exception(function () use ($asserter) {446 $value = uniqid();447 $asserter->isReferenceTo($value);448 })449 ->isInstanceOf(\logicException::class)450 ->hasMessage('Value is not set by reference')451 ->if(452 $asserter->setByReferenceWith($value),453 $reference = & $value,454 $this->calling($locale)->_ = $localizedMessage = uniqid(),455 $this->calling($analyzer)->getTypeOf = $type = uniqid()456 )457 ->then458 ->object($asserter->isReferenceTo($reference))->isIdenticalTo($asserter)459 ->exception(function () use ($asserter, & $notReference) {460 $notReference = uniqid();461 $asserter->isReferenceTo($notReference);462 })463 ->isInstanceOf(atoum\asserter\exception::class)464 ->hasMessage($localizedMessage)465 ->mock($locale)->call('_')->withArguments('%s is not a reference to %s', $asserter, $type)->once466 ->if(467 $value = new \exception(),468 $asserter->setByReferenceWith($value)469 )470 ->then471 ->object($asserter->isReferenceTo($reference))->isIdenticalTo($asserter)472 ->exception(function () use ($asserter, & $notReference) {473 $notReference = new \exception();474 $asserter->isReferenceTo($notReference);475 })476 ->isInstanceOf(atoum\asserter\exception::class)477 ->hasMessage($localizedMessage)478 ->mock($locale)->call('_')->withArguments('%s is not a reference to %s', $asserter, $type)->twice479 ->exception(function () use ($asserter, & $notReference, & $failMessage) {480 $notReference = new \exception();481 $asserter->isReferenceTo($notReference, $failMessage = uniqid());482 })483 ->isInstanceOf(atoum\asserter\exception::class)484 ->hasMessage($failMessage)485 ;486 }487 public function testIsNotFalse()488 {489 $this490 ->given(491 $asserter = $this->newTestedInstance492 ->setLocale($locale = new \mock\atoum\locale())493 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())494 )495 ->then496 ->exception(function () use ($asserter) {497 $asserter->isNotFalse();498 })499 ->isInstanceOf(\logicException::class)500 ->hasMessage('Value is undefined')501 ->exception(function () use ($asserter) {502 $asserter->isNotFalse;503 })504 ->isInstanceOf(\logicException::class)505 ->hasMessage('Value is undefined')506 ->if($asserter->setWith(uniqid()))507 ->then508 ->object($asserter->isNotFalse())->isIdenticalTo($asserter)509 ->object($asserter->isNotFalse)->isIdenticalTo($asserter)510 ->if(511 $asserter->setWith(false),512 $this->calling($locale)->_ = $localizedMessage = uniqid()513 )514 ->then515 ->exception(function () use ($asserter) {516 $asserter->isNotFalse();517 })518 ->isInstanceOf(atoum\asserter\exception::class)519 ->hasMessage($localizedMessage)520 ->mock($locale)->call('_')->withArguments('%s is false', $asserter)->atLeastOnce()521 ->exception(function () use ($asserter) {522 $asserter->isNotFalse;523 })524 ->isInstanceOf(atoum\asserter\exception::class)525 ->hasMessage($localizedMessage)526 ->mock($locale)->call('_')->withArguments('%s is false', $asserter)->atLeastOnce()527 ->exception(function () use ($asserter, & $failMessage) {528 $asserter->isNotFalse($failMessage = uniqid());529 })530 ->isInstanceOf(atoum\asserter\exception::class)531 ->hasMessage($failMessage)532 ;533 }534 public function testIsNotTrue()535 {536 $this537 ->given(538 $asserter = $this->newTestedInstance539 ->setLocale($locale = new \mock\atoum\locale())540 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())541 )542 ->then543 ->exception(function () use ($asserter) {544 $asserter->isNotTrue();545 })546 ->isInstanceOf(\logicException::class)547 ->hasMessage('Value is undefined')548 ->exception(function () use ($asserter) {549 $asserter->isNotTrue;550 })551 ->isInstanceOf(\logicException::class)552 ->hasMessage('Value is undefined')553 ->if($asserter->setWith(uniqid()))554 ->then555 ->object($asserter->isNotTrue())->isIdenticalTo($asserter)556 ->object($asserter->isNotTrue)->isIdenticalTo($asserter)557 ->if(558 $asserter->setWith(true),559 $this->calling($locale)->_ = $localizedMessage = uniqid()560 )561 ->then562 ->exception(function () use ($asserter) {563 $asserter->isNotTrue();564 })565 ->isInstanceOf(atoum\asserter\exception::class)566 ->hasMessage($localizedMessage)567 ->mock($locale)->call('_')->withArguments('%s is true', $asserter)->atLeastOnce()568 ->exception(function () use ($asserter) {569 $asserter->isNotTrue;570 })571 ->isInstanceOf(atoum\asserter\exception::class)572 ->hasMessage($localizedMessage)573 ->mock($locale)->call('_')->withArguments('%s is true', $asserter)->atLeastOnce()574 ->exception(function () use ($asserter, & $failMessage) {575 $asserter->isNotTrue($failMessage = uniqid());576 })577 ->isInstanceOf(atoum\asserter\exception::class)578 ->hasMessage($failMessage)579 ;580 }581 public function testIsCallable()582 {583 $this584 ->given(585 $asserter = $this->newTestedInstance586 ->setLocale($locale = new \mock\atoum\locale())587 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())588 )589 ->then590 ->exception(function () use ($asserter) {591 $asserter->isCallable();592 })593 ->isInstanceOf(\logicException::class)594 ->hasMessage('Value is undefined')595 ->exception(function () use ($asserter) {596 $asserter->isCallable;597 })598 ->isInstanceOf(\logicException::class)599 ->hasMessage('Value is undefined')600 ->if($asserter->setWith(function () {601 }))602 ->then603 ->object($asserter->isCallable())->isIdenticalTo($asserter)604 ->object($asserter->isCallable)->isIdenticalTo($asserter)605 ->if(606 $asserter->setWith(uniqid()),607 $this->calling($locale)->_ = $localizedMessage = uniqid()608 )609 ->then610 ->exception(function () use ($asserter) {611 $asserter->isCallable();612 })613 ->isInstanceOf(atoum\asserter\exception::class)614 ->hasMessage($localizedMessage)615 ->mock($locale)->call('_')->withArguments('%s is not callable', $asserter)->atLeastOnce()616 ->exception(function () use ($asserter) {617 $asserter->isCallable;618 })619 ->isInstanceOf(atoum\asserter\exception::class)620 ->hasMessage($localizedMessage)621 ->mock($locale)->call('_')->withArguments('%s is not callable', $asserter)->atLeastOnce()622 ->exception(function () use ($asserter, & $failMessage) {623 $asserter->isCallable($failMessage = uniqid());624 })625 ->isInstanceOf(atoum\asserter\exception::class)626 ->hasMessage($failMessage)627 ;628 }629 public function testIsNotCallable()630 {631 $this632 ->given(633 $asserter = $this->newTestedInstance634 ->setLocale($locale = new \mock\atoum\locale())635 )636 ->then637 ->exception(function () use ($asserter) {638 $asserter->isNotCallable();639 })640 ->isInstanceOf(\logicException::class)641 ->hasMessage('Value is undefined')642 ->exception(function () use ($asserter) {643 $asserter->isNotCallable;644 })645 ->isInstanceOf(\logicException::class)646 ->hasMessage('Value is undefined')647 ->if($asserter->setWith(uniqid()))648 ->then649 ->object($asserter->isNotCallable())->isIdenticalTo($asserter)650 ->object($asserter->isNotCallable)->isIdenticalTo($asserter)651 ->if(652 $asserter->setWith(function () {653 }),654 $this->calling($locale)->_ = $localizedMessage = uniqid()655 )656 ->then657 ->exception(function () use ($asserter) {658 $asserter->isNotCallable();659 })660 ->isInstanceOf(atoum\asserter\exception::class)661 ->hasMessage($localizedMessage)662 ->mock($locale)->call('_')->withArguments('%s is callable', $asserter)->atLeastOnce()663 ->exception(function () use ($asserter) {664 $asserter->isNotCallable;665 })666 ->isInstanceOf(atoum\asserter\exception::class)667 ->hasMessage($localizedMessage)668 ->mock($locale)->call('_')->withArguments('%s is callable', $asserter)->atLeastOnce()669 ->exception(function () use ($asserter, & $message) {670 $asserter->isNotCallable($message = uniqid());671 })672 ->isInstanceOf(atoum\asserter\exception::class)673 ->hasMessage($message)674 ;675 }676}...

Full Screen

Full Screen

phpArray.php

Source:phpArray.php Github

copy

Full Screen

...29 ->if($asserter = new testedClass($generator = new asserter\generator()))30 ->then31 ->exception(function() use ($asserter, & $value) { $asserter->setWith($value = uniqid()); })32 ->isInstanceOf('mageekguy\atoum\asserter\exception')33 ->hasMessage(sprintf($generator->getLocale()->_('%s is not an array'), $asserter->getTypeOf($value)))34 ->object($asserter->setWith($value = array()))->isIdenticalTo($asserter)35 ->array($asserter->getValue())->isEqualTo($value)36 ;37 }38 public function testHasSize()39 {40 $this41 ->if($asserter = new testedClass($generator = new asserter\generator()))42 ->then43 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })44 ->isInstanceOf('mageekguy\atoum\exceptions\logic')45 ->hasMessage('Array is undefined')46 ->if($asserter->setWith(array()))47 ->then48 ->exception(function() use ($asserter, & $size) { $asserter->hasSize($size = rand(1, PHP_INT_MAX)); })49 ->isInstanceOf('mageekguy\atoum\asserter\exception')50 ->hasMessage(sprintf($generator->getLocale()->_('%s has not size %d'), $asserter, $size))51 ->exception(function() use ($asserter, & $size, & $message) { $asserter->hasSize($size = rand(1, PHP_INT_MAX), $message = uniqid()); })52 ->isInstanceOf('mageekguy\atoum\asserter\exception')53 ->hasMessage($message)54 ->object($asserter->hasSize(0))->isIdenticalTo($asserter)55 ;56 }57 public function testIsEmpty()58 {59 $this->assert60 ->if($asserter = new testedClass($generator = new asserter\generator()))61 ->then62 ->exception(function() use ($asserter) { $asserter->isEmpty(); })63 ->isInstanceOf('mageekguy\atoum\exceptions\logic')64 ->hasMessage('Array is undefined')65 ->if($asserter->setWith(array(uniqid())))66 ->then67 ->exception(function() use ($asserter) { $asserter->isEmpty(); })68 ->isInstanceOf('mageekguy\atoum\asserter\exception')69 ->hasMessage(sprintf($generator->getLocale()->_('%s is not empty'), $asserter))70 ->exception(function() use ($asserter, & $message) { $asserter->isEmpty($message = uniqid()); })71 ->isInstanceOf('mageekguy\atoum\asserter\exception')72 ->hasMessage($message)73 ->if($asserter->setWith(array()))74 ->then75 ->object($asserter->isEmpty())->isIdenticalTo($asserter)76 ;77 }78 public function testIsNotEmpty()79 {80 $this81 ->if($asserter = new testedClass($generator = new asserter\generator()))82 ->then83 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })84 ->isInstanceOf('mageekguy\atoum\exceptions\logic')85 ->hasMessage('Array is undefined')86 ->if($asserter->setWith(array()))87 ->then88 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })89 ->isInstanceOf('mageekguy\atoum\asserter\exception')90 ->hasMessage(sprintf($generator->getLocale()->_('%s is empty'), $asserter))91 ->exception(function() use ($asserter, & $message) { $asserter->isNotEmpty($message = uniqid()); })92 ->isInstanceOf('mageekguy\atoum\asserter\exception')93 ->hasMessage($message)94 ->if($asserter->setWith(array(uniqid())))95 ->then96 ->object($asserter->isNotEmpty())->isIdenticalTo($asserter)97 ;98 }99 public function testAtKey()100 {101 $this102 ->if($asserter = new testedClass($generator = new asserter\generator()))103 ->then104 ->exception(function() use ($asserter) { $asserter->atKey(uniqid()); })105 ->isInstanceOf('mageekguy\atoum\exceptions\logic')106 ->hasMessage('Array is undefined')107 ->if($asserter->setWith(array(uniqid(), uniqid(), $data = rand(1, PHP_INT_MAX), uniqid(), uniqid())))108 ->object($asserter->atKey(0))->isIdenticalTo($asserter)109 ->object($asserter->atKey('0'))->isIdenticalTo($asserter)110 ->object($asserter->atKey(1))->isIdenticalTo($asserter)111 ->object($asserter->atKey(2))->isIdenticalTo($asserter)112 ->object($asserter->atKey(3))->isIdenticalTo($asserter)113 ->object($asserter->atKey(4))->isIdenticalTo($asserter)114 ->exception(function() use ($asserter, & $key) { $asserter->atKey($key = rand(5, PHP_INT_MAX)); })115 ->isInstanceOf('mageekguy\atoum\asserter\exception')116 ->hasMessage(sprintf($generator->getLocale()->_('%s has no key %s'), $asserter, $asserter->getTypeOf($key)))117 ->exception(function() use ($asserter, & $key, & $message) { $asserter->atKey($key = rand(5, PHP_INT_MAX), $message = uniqid()); })118 ->isInstanceOf('mageekguy\atoum\asserter\exception')119 ->hasMessage($message)120 ;121 }122 public function testContains()123 {124 $this125 ->if($asserter = new testedClass($generator = new asserter\generator()))126 ->then127 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })128 ->isInstanceOf('mageekguy\atoum\exceptions\logic')129 ->hasMessage('Array is undefined')130 ->if($asserter->setWith(array(uniqid(), uniqid(), $data = rand(1, PHP_INT_MAX), uniqid(), uniqid())))131 ->then132 ->exception(function() use ($asserter, & $notInArray) { $asserter->contains($notInArray = uniqid()); })133 ->isInstanceOf('mageekguy\atoum\asserter\exception')134 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain %s'), $asserter, $asserter->getTypeOf($notInArray)))135 ->object($asserter->contains($data))->isIdenticalTo($asserter)136 ->object($asserter->contains((string) $data))->isIdenticalTo($asserter)137 ->exception(function() use ($asserter, $data) { $asserter->atKey(0)->contains($data); })138 ->isInstanceOf('mageekguy\atoum\asserter\exception')139 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain %s at key %s'), $asserter, $asserter->getTypeOf($data), $asserter->getTypeOf(0)))140 ->object($asserter->contains($data))->isIdenticalTo($asserter)141 ->object($asserter->atKey(2)->contains($data))->isIdenticalTo($asserter)142 ;143 }144 public function testNotContains()145 {146 $this147 ->if($asserter = new testedClass($generator = new asserter\generator()))148 ->then149 ->exception(function() use ($asserter) { $asserter->notContains(uniqid()); })150 ->isInstanceOf('mageekguy\atoum\exceptions\logic')151 ->hasMessage('Array is undefined')152 ->if($asserter->setWith(array(uniqid(), uniqid(), $inArray = uniqid(), uniqid(), uniqid())))153 ->then154 ->object($asserter->notContains(uniqid()))->isIdenticalTo($asserter)155 ->exception(function() use ($asserter, $inArray) { $asserter->notContains($inArray); })156 ->isInstanceOf('mageekguy\atoum\asserter\exception')157 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s'), $asserter, $asserter->getTypeOf($inArray)))158 ->exception(function() use ($asserter, $inArray, & $message) { $asserter->notContains($inArray, $message = uniqid()); })159 ->isInstanceOf('mageekguy\atoum\asserter\exception')160 ->hasMessage($message)161 ->exception(function() use($asserter, $inArray){ $asserter->notContains((string) $inArray); })162 ->isInstanceOf('mageekguy\atoum\asserter\exception')163 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s'), $asserter, $asserter->getTypeOf((string) $inArray)))164 ->exception(function() use($asserter, $inArray, & $message){ $asserter->notContains((string) $inArray, $message = uniqid()); })165 ->isInstanceOf('mageekguy\atoum\asserter\exception')166 ->hasMessage($message)167 ->object($asserter->atKey(0)->notContains($inArray))->isIdenticalTo($asserter)168 ->object($asserter->atKey(1)->notContains($inArray))->isIdenticalTo($asserter)169 ->object($asserter->atKey(3)->notContains($inArray))->isIdenticalTo($asserter)170 ->object($asserter->atKey(4)->notContains($inArray))->isIdenticalTo($asserter)171 ->exception(function() use ($asserter, $inArray) { $asserter->notContains($inArray); })172 ->isInstanceOf('mageekguy\atoum\asserter\exception')173 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s'), $asserter, $asserter->getTypeOf($inArray)))174 ->exception(function() use ($asserter, $inArray) { $asserter->atKey(2)->notContains($inArray); })175 ->isInstanceOf('mageekguy\atoum\asserter\exception')176 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s at key %s'), $asserter, $asserter->getTypeOf($inArray), $asserter->getTypeOf(2)))177 ->exception(function() use ($asserter, $inArray) { $asserter->atKey('2')->notContains($inArray); })178 ->isInstanceOf('mageekguy\atoum\asserter\exception')179 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s at key %s'), $asserter, $asserter->getTypeOf($inArray), $asserter->getTypeOf('2')))180 ;181 }182 public function testStrictlyContains()183 {184 $this185 ->if($asserter = new testedClass($generator = new asserter\generator()))186 ->then187 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })188 ->isInstanceOf('mageekguy\atoum\exceptions\logic')189 ->hasMessage('Array is undefined')190 ->and($asserter->setWith(array(1, 2, 3, 4, 5, '3')))191 ->then192 ->exception(function() use ($asserter) {$asserter->strictlyContains('1'); })193 ->isInstanceOf('mageekguy\atoum\asserter\exception')194 ->hasMessage(sprintf($generator->getLocale()->_('%s does not strictly contain %s'), $asserter, $asserter->getTypeOf('1')))195 ->exception(function() use ($asserter, & $message) {$asserter->strictlyContains('1', $message = uniqid()); })196 ->isInstanceOf('mageekguy\atoum\asserter\exception')197 ->hasMessage($message)198 ->object($asserter->strictlyContains(1))->isIdenticalTo($asserter)199 ->exception(function() use ($asserter) { $asserter->atKey(0)->strictlyContains(2); })200 ->isInstanceOf('mageekguy\atoum\asserter\exception')201 ->hasMessage(sprintf($generator->getLocale()->_('%s does not strictly contain %s at key %s'), $asserter, $asserter->getTypeOf(2), $asserter->getTypeOf(0)))202 ->object($asserter->strictlyContains(2))->isIdenticalTo($asserter)203 ->object($asserter->atKey(2)->strictlyContains(3))->isIdenticalTo($asserter)204 ->exception(function() use ($asserter) { $asserter->atKey(2)->strictlyContains('3'); })205 ->isInstanceOf('mageekguy\atoum\asserter\exception')206 ->hasMessage(sprintf($generator->getLocale()->_('%s does not strictly contain %s at key %s'), $asserter, $asserter->getTypeOf('3'), $asserter->getTypeOf(2)))207 ;208 }209 public function testStrictlyNotContains()210 {211 $this212 ->if($asserter = new testedClass($generator = new asserter\generator()))213 ->then214 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })215 ->isInstanceOf('mageekguy\atoum\exceptions\logic')216 ->hasMessage('Array is undefined')217 ->if($asserter->setWith(array(1, 2, 3, 4, 5, '6')))218 ->then219 ->exception(function() use ($asserter) {$asserter->strictlyNotContains(1); })220 ->isInstanceOf('mageekguy\atoum\asserter\exception')221 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s'), $asserter, $asserter->getTypeOf(1)))222 ->exception(function() use ($asserter, & $message) {$asserter->strictlyNotContains(1, $message = uniqid()); })223 ->isInstanceOf('mageekguy\atoum\asserter\exception')224 ->hasMessage($message)225 ->object($asserter->strictlyNotContains('1'))->isIdenticalTo($asserter)226 ->object($asserter->atKey(1)->strictlyNotContains(1))->isIdenticalTo($asserter)227 ->object($asserter->atKey(2)->strictlyNotContains(1))->isIdenticalTo($asserter)228 ->object($asserter->atKey(3)->strictlyNotContains(1))->isIdenticalTo($asserter)229 ->object($asserter->atKey(4)->strictlyNotContains(1))->isIdenticalTo($asserter)230 ->exception(function() use ($asserter) { $asserter->strictlyNotContains(1); })231 ->isInstanceOf('mageekguy\atoum\asserter\exception')232 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s'), $asserter, $asserter->getTypeOf(1)))233 ->exception(function() use ($asserter) { $asserter->atKey(0)->strictlyNotContains(1); })234 ->isInstanceOf('mageekguy\atoum\asserter\exception')235 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s at key %s'), $asserter, $asserter->getTypeOf(1), $asserter->getTypeOf(0)))236 ->exception(function() use ($asserter) { $asserter->atKey('0')->strictlyNotContains(1); })237 ->isInstanceOf('mageekguy\atoum\asserter\exception')238 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s at key %s'), $asserter, $asserter->getTypeOf(1), $asserter->getTypeOf('0')))239 ;240 }241 public function testContainsValues()242 {243 $this244 ->if($asserter = new testedClass($generator = new asserter\generator()))245 ->then246 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })247 ->isInstanceOf('mageekguy\atoum\exceptions\logic')248 ->hasMessage('Array is undefined')249 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))250 ->then251 ->exception(function() use ($asserter) { $asserter->containsValues(array(6)); })252 ->isInstanceOf('mageekguy\atoum\asserter\exception')253 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain values %s'), $asserter, $asserter->getTypeOf(array(6))))254 ->exception(function() use ($asserter, & $message) { $asserter->containsValues(array(6), $message = uniqid()); })255 ->isInstanceOf('mageekguy\atoum\asserter\exception')256 ->hasMessage($message)257 ->exception(function() use ($asserter) { $asserter->containsValues(array('6')); })258 ->isInstanceOf('mageekguy\atoum\asserter\exception')259 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain values %s'), $asserter, $asserter->getTypeOf(array('6'))))260 ->exception(function() use ($asserter, & $message) { $asserter->containsValues(array('6'), $message = uniqid()); })261 ->isInstanceOf('mageekguy\atoum\asserter\exception')262 ->hasMessage($message)263 ->object($asserter->containsValues(array(1)))->isIdenticalTo($asserter)264 ->object($asserter->containsValues(array(1, 2, 4)))->isIdenticalTo($asserter)265 ->object($asserter->containsValues(array('1', 2, '4')))->isIdenticalTo($asserter)266 ;267 }268 public function testNotContainsValues()269 {270 $this271 ->if($asserter = new testedClass($generator = new asserter\generator()))272 ->then273 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })274 ->isInstanceOf('mageekguy\atoum\exceptions\logic')275 ->hasMessage('Array is undefined')276 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))277 ->then278 ->exception(function() use ($asserter) { $asserter->notContainsValues(array(1, 6)); })279 ->isInstanceOf('mageekguy\atoum\asserter\exception')280 ->hasMessage(sprintf($generator->getLocale()->_('%s should not contain values %s'), $asserter, $asserter->getTypeOf(array(1))))281 ->exception(function() use ($asserter, & $message) { $asserter->notContainsValues(array(1, 6), $message = uniqid()); })282 ->isInstanceOf('mageekguy\atoum\asserter\exception')283 ->hasMessage($message)284 ->exception(function() use ($asserter, & $message) { $asserter->notContainsValues(array('1', '6'), $message = uniqid()); })285 ->isInstanceOf('mageekguy\atoum\asserter\exception')286 ->hasMessage($message)287 ->object($asserter->containsValues(array(1)))->isIdenticalTo($asserter)288 ->object($asserter->containsValues(array(1, 2, 4)))->isIdenticalTo($asserter)289 ->object($asserter->containsValues(array('1', 2, '4')))->isIdenticalTo($asserter)290 ;291 }292 public function testStrictlyContainsValues()293 {294 $this295 ->if($asserter = new testedClass($generator = new asserter\generator()))296 ->then297 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })298 ->isInstanceOf('mageekguy\atoum\exceptions\logic')299 ->hasMessage('Array is undefined')300 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))301 ->then302 ->exception(function() use ($asserter) { $asserter->strictlyContainsValues(array(6)); })303 ->isInstanceOf('mageekguy\atoum\asserter\exception')304 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain strictly values %s'), $asserter, $asserter->getTypeOf(array(6))))305 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array(6), $message = uniqid()); })306 ->isInstanceOf('mageekguy\atoum\asserter\exception')307 ->hasMessage($message)308 ->exception(function() use ($asserter) { $asserter->strictlyContainsValues(array('6')); })309 ->isInstanceOf('mageekguy\atoum\asserter\exception')310 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain strictly values %s'), $asserter, $asserter->getTypeOf(array('6'))))311 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array('6'), $message = uniqid()); })312 ->isInstanceOf('mageekguy\atoum\asserter\exception')313 ->hasMessage($message)314 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array('1'), $message = uniqid()); })315 ->isInstanceOf('mageekguy\atoum\asserter\exception')316 ->hasMessage($message)317 ->object($asserter->strictlyContainsValues(array(1)))->isIdenticalTo($asserter)318 ->object($asserter->strictlyContainsValues(array(1, 2, 4)))->isIdenticalTo($asserter)319 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array('1', 2, '4'), $message = uniqid()); })320 ->isInstanceOf('mageekguy\atoum\asserter\exception')321 ->hasMessage($message)322 ;323 }324 public function testStrictlyNotContainsValues()325 {326 $this327 ->if($asserter = new testedClass($generator = new asserter\generator()))328 ->then329 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })330 ->isInstanceOf('mageekguy\atoum\exceptions\logic')331 ->hasMessage('Array is undefined')332 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))333 ->then334 ->exception(function() use ($asserter) { $asserter->strictlyNotContainsValues(array(1)); })335 ->isInstanceOf('mageekguy\atoum\asserter\exception')336 ->hasMessage(sprintf($generator->getLocale()->_('%s should not contain strictly values %s'), $asserter, $asserter->getTypeOf(array(1))))337 ->exception(function() use ($asserter, & $message) { $asserter->strictlyNotContainsValues(array(1), $message = uniqid()); })338 ->isInstanceOf('mageekguy\atoum\asserter\exception')339 ->hasMessage($message)340 ->exception(function() use ($asserter, & $message) { $asserter->strictlyNotContainsValues(array(1, '2', 3), $message = uniqid()); })341 ->isInstanceOf('mageekguy\atoum\asserter\exception')342 ->hasMessage($message)343 ->object($asserter->strictlyNotContainsValues(array('1')))->isIdenticalTo($asserter)344 ->object($asserter->strictlyNotContainsValues(array(6, 7, '2', 8)))->isIdenticalTo($asserter)345 ;346 }347 public function testHasKey()348 {349 $this350 ->if($asserter = new testedClass($generator = new asserter\generator()))351 ->then352 ->exception(function() use ($asserter) { $asserter->hasKey(rand(0, PHP_INT_MAX)); })353 ->isInstanceOf('mageekguy\atoum\exceptions\logic')354 ->hasMessage('Array is undefined')355 ->if($asserter->setWith(array()))356 ->then357 ->exception(function() use ($asserter, & $key) { $asserter->hasKey($key = rand(1, PHP_INT_MAX)); })358 ->isInstanceOf('mageekguy\atoum\asserter\exception')359 ->hasMessage(sprintf($generator->getLocale()->_('%s has no key %s'), $asserter, $asserter->getTypeOf($key)))360 ->exception(function() use ($asserter, & $key, & $message) { $asserter->hasKey($key = rand(1, PHP_INT_MAX), $message = uniqid()); })361 ->isInstanceOf('mageekguy\atoum\asserter\exception')362 ->hasMessage($message)363 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))364 ->then365 ->object($asserter->hasKey(0))->isIdenticalTo($asserter)366 ->object($asserter->hasKey(1))->isIdenticalTo($asserter)367 ->object($asserter->hasKey(2))->isIdenticalTo($asserter)368 ->object($asserter->hasKey(3))->isIdenticalTo($asserter)369 ->object($asserter->hasKey(4))->isIdenticalTo($asserter)370 ->exception(function() use ($asserter) { $asserter->hasKey(5); })371 ->isInstanceOf('mageekguy\atoum\asserter\exception')372 ->hasMessage(sprintf($generator->getLocale()->_('%s has no key %s'), $asserter, $asserter->getTypeOf(5)))373 ->exception(function() use ($asserter, & $message) { $asserter->hasKey(5, $message = uniqid()); })374 ->isInstanceOf('mageekguy\atoum\asserter\exception')375 ->hasMessage($message)376 ;377 }378 public function testNotHasKey()379 {380 $this381 ->if($asserter = new testedClass($generator = new asserter\generator()))382 ->then383 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })384 ->isInstanceOf('mageekguy\atoum\exceptions\logic')385 ->hasMessage('Array is undefined')386 ->if($asserter->setWith(array()))387 ->then388 ->object($asserter->notHasKey(1))->isIdenticalTo($asserter)389 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))390 ->then391 ->exception(function() use ($asserter) { $asserter->notHasKey(0); })392 ->isInstanceOf('mageekguy\atoum\asserter\exception')393 ->hasMessage(sprintf($generator->getLocale()->_('%s has a key %s'), $asserter, $asserter->getTypeOf(0)))394 ->exception(function() use ($asserter, & $message) { $asserter->notHasKey(0, $message = uniqid()); })395 ->isInstanceOf('mageekguy\atoum\asserter\exception')396 ->hasMessage($message)397 ->object($asserter->notHasKey(5))->isIdenticalTo($asserter)398 ;399 }400 public function testNotHasKeys()401 {402 $this403 ->if($asserter = new testedClass($generator = new asserter\generator()))404 ->then405 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })406 ->isInstanceOf('mageekguy\atoum\exceptions\logic')407 ->hasMessage('Array is undefined')408 ->if($asserter->setWith(array()))409 ->then410 ->object($asserter->notHasKeys(array(1)))->isIdenticalTo($asserter)411 ->object($asserter->notHasKeys(array(0, 1)))->isIdenticalTo($asserter)412 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))413 ->then414 ->exception(function() use ($asserter) { $asserter->notHasKeys(array(0, 'premier', 2)); })415 ->isInstanceOf('mageekguy\atoum\asserter\exception')416 ->hasMessage(sprintf($generator->getLocale()->_('%s should not have keys %s'), $asserter, $asserter->getTypeOf(array(0, 2))))417 ->exception(function() use ($asserter, & $message) { $asserter->notHasKeys(array(0, 'premier', 2), $message = uniqid()); })418 ->isInstanceOf('mageekguy\atoum\asserter\exception')419 ->hasMessage($message)420 ->object($asserter->notHasKeys(array(5, '6')))->isIdenticalTo($asserter)421 ;422 }423 public function testHasKeys()424 {425 $this426 ->if($asserter = new testedClass($generator = new asserter\generator()))427 ->then428 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })429 ->isInstanceOf('mageekguy\atoum\exceptions\logic')430 ->hasMessage('Array is undefined')431 ->if($asserter->setWith(array()))432 ->then433 ->exception(function() use ($asserter) { $asserter->hasKeys(array(0)); })434 ->isInstanceOf('mageekguy\atoum\asserter\exception')435 ->hasMessage(sprintf($generator->getLocale()->_('%s should have keys %s'), $asserter, $asserter->getTypeOf(array(0))))436 ->exception(function() use ($asserter, & $message) { $asserter->hasKeys(array(0), $message = uniqid()); })437 ->isInstanceOf('mageekguy\atoum\asserter\exception')438 ->hasMessage($message)439 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))440 ->then441 ->exception(function() use ($asserter) { $asserter->hasKeys(array(0, 'first', 2, 'second')); })442 ->isInstanceOf('mageekguy\atoum\asserter\exception')443 ->hasMessage(sprintf($generator->getLocale()->_('%s should have keys %s'), $asserter, $asserter->getTypeOf(array('first', 'second'))))444 ->exception(function() use ($asserter, & $message) { $asserter->hasKeys(array(0, 'first', 2, 'second'), $message = uniqid()); })445 ->isInstanceOf('mageekguy\atoum\asserter\exception')446 ->hasMessage($message)447 ->object($asserter->hasKeys(array(0, 2, 4)))->isIdenticalTo($asserter)448 ;449 }450}...

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1try{2 throw new Exception();3}catch(Exception $e){4 if($e->hasMessage()){5 echo "Exception has a message";6 }else{7 echo "Exception has no message";8 }9}10PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative)11PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 2)12PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 3)13PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 4)14PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 5)15PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 6)16PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 7)17PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 8)18PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 9)19PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 10)20PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 11)21PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 12)22PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 13)23PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 14)24PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 15)25PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 16)26PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 17)27PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 18)28PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 19)29PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 20)30PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 21)31PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 22)32PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 23)33PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 24)34PHP | Exception Handling for User Defined Exceptions using try...catch (Alternative 25)

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1try{2 throw new Exception("This is an exception");3}catch(Exception $e){4 if($e->hasMessage()){5 echo $e->getMessage();6 }7}8PHP | Exception Handling | set_exception_handler()9PHP | Exception Handling | get_class()10PHP | Exception Handling | get_class() function11PHP | Exception Handling | getTraceAsString() function12PHP | Exception Handling | getTrace() function13PHP | Exception Handling | getMessage() function14PHP | Exception Handling | getCode() function15PHP | Exception Handling | getPrevious() function16PHP | Exception Handling | getLine() function17PHP | Exception Handling | getFile() function18PHP | Exception Handling | getTrace() function19PHP | Exception Handling | getTraceAsString() function

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1{2 throw new Exception('This is an exception');3}4catch(Exception $e)5{6 if($e->hasMessage())7 {8 echo $e->getMessage();9 }10}11{12 throw new Exception('This is an exception');13}14catch(Exception $e)15{16 echo $e->getMessage();17}18{19 throw new Exception();20}21catch(Exception $e)22{23 if($e->hasMessage())24 {25 echo $e->getMessage();26 }27}28{29 throw new Exception();30}31catch(Exception $e)32{33 echo $e->getMessage();34}

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1{2throw new Exception("This is a message");3}4catch(Exception $e)5{6if($e->hasMessage())7{8echo $e->getMessage();9}10}11{12throw new Exception("This is a message");13}14catch(Exception $e)15{16if($e->hasMessage())17{18echo $e->getMessage();19}20}21{22throw new Exception("This is a message");23}24catch(Exception $e)25{26if($e->hasMessage())27{28echo $e->getMessage();29}30}31{32throw new Exception("This is a message");33}34catch(Exception $e)35{36if($e->hasMessage())37{38echo $e->getMessage();39}40}41{42throw new Exception("This is a message");43}44catch(Exception $e)45{46if($e->hasMessage())47{48echo $e->getMessage();49}50}51{52throw new Exception("This is a message");53}54catch(Exception $e)55{56if($e->hasMessage())57{58echo $e->getMessage();59}60}61{62throw new Exception("This is a message");63}64catch(Exception $e)65{66if($e->hasMessage())67{68echo $e->getMessage();69}70}71{72throw new Exception("This is a message");73}74catch(Exception $e)75{76if($e->hasMessage())77{78echo $e->getMessage();79}80}81{82throw new Exception("This is a message");83}84catch(Exception $e)85{86if($e->hasMessage())87{88echo $e->getMessage();89}90}91{92throw new Exception("This is a message");93}94catch(Exception $e)95{96if($

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1{2throw new Exception("My Exception");3}4catch(Exception $e)5{6if($e->hasMessage())7{8echo "Exception has message";9}10{11echo "Exception has no message";12}13}14Recommended Posts: PHP | Exception::getTraceAsString() Method15PHP | Exception::getTrace() Method16PHP | Exception::getPrevious() Method17PHP | Exception::getLine() Method18PHP | Exception::getFile() Method19PHP | Exception::getCode() Method20PHP | Exception::getMessage() Method21PHP | Exception::getPrevious() Method22PHP | Exception::getTrace() Method23PHP | Exception::getTraceAsString() Method24PHP | Exception::getCode() Method25PHP | Exception::getFile() Method26PHP | Exception::getLine() Method27PHP | Exception::getMessage() Method28PHP | Exception::getPrevious() Method29PHP | Exception::getTrace() Method30PHP | Exception::getTraceAsString() Method31PHP | Exception::getCode() Method32PHP | Exception::getFile() Method33PHP | Exception::getLine() Method34PHP | Exception::getMessage() Method35PHP | Exception::getPrevious() Method36PHP | Exception::getTrace() Method37PHP | Exception::getTraceAsString() Method38PHP | Exception::getCode() Method39PHP | Exception::getFile() Method40PHP | Exception::getLine() Method41PHP | Exception::getMessage() Method42PHP | Exception::getPrevious() Method43PHP | Exception::getTrace() Method44PHP | Exception::getTraceAsString() Method45PHP | Exception::getCode() Method46PHP | Exception::getFile() Method47PHP | Exception::getLine() Method48PHP | Exception::getMessage() Method49PHP | Exception::getPrevious() Method50PHP | Exception::getTrace() Method51PHP | Exception::getTraceAsString() Method52PHP | Exception::getCode() Method53PHP | Exception::getFile() Method54PHP | Exception::getLine() Method55PHP | Exception::getMessage() Method56PHP | Exception::getPrevious() Method57PHP | Exception::getTrace() Method58PHP | Exception::getTraceAsString() Method59PHP | Exception::getCode() Method60PHP | Exception::getFile() Method61PHP | Exception::getLine() Method62PHP | Exception::getMessage() Method63PHP | Exception::getPrevious() Method

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1{2 throw new Exception('Test Message');3}4catch(Exception $e)5{6 if($e->hasMessage())7 {8 echo $e->getMessage();9 }10}11{12 throw new Exception('Test Message');13}14catch(Exception $e)15{16 if($e->hasMessage('Test Message'))17 {18 echo $e->getMessage();19 }20}

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1try{2 throw new Exception('Exception message');3}catch(Exception $e){4 if($e->hasMessage()){5 echo 'Exception has a message';6 }else{7 echo 'Exception has no message';8 }9}10try{11 throw new Exception('Exception message');12}catch(Exception $e){13 echo $e->getMessage();14}15try{16 throw new Exception('Exception message', 10);17}catch(Exception $e){18 echo $e->getCode();19}20try{21 throw new Exception('Exception message');22}catch(Exception $e){23 echo $e->getFile();24}25try{26 throw new Exception('Exception message');27}catch(Exception $e){28 echo $e->getLine();29}30try{31 throw new Exception('Exception message');32}catch(Exception $e){33 print_r($e->getTrace());34}35 (

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1{2throw new Exception('Exception Occured');3}4catch(Exception $e)5{6if($e->hasMessage())7{8echo $e->getMessage();9}10}

Full Screen

Full Screen

hasMessage

Using AI Code Generation

copy

Full Screen

1try{2 throw new Exception('Error Message');3}catch(Exception $e){4 if($e->hasMessage()){5 echo 'has message';6 }7}8getPrevious()9try{10 try{11 throw new Exception('Error Message');12 }catch(Exception $e){13 throw new Exception('Error Message 2', 0, $e);14 }15}catch(Exception $e){16 if($e->getPrevious()){17 echo 'has previous exception';18 }19}20getTrace()21try{22 throw new Exception('Error Message');23}catch(Exception $e){24 echo '<pre>';25 print_r($e->getTrace());26 echo '</pre>';27}28 (29 [function] => {main}30 (31getTraceAsString()32try{33 throw new Exception('Error Message');34}catch(Exception $e){35 echo $e->getTraceAsString();36}37#0 /home/username/public_html/1.php(5): {main}()38__toString()39try{40 throw new Exception('Error Message');41}catch(Exception $e){42 echo $e;43}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger hasMessage code on LambdaTest Cloud Grid

Execute automation tests with hasMessage on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful