Esempio n. 1
0
 public function testThrice()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserters\\adapter\\exceptions\\logic')->hasMessage('Adapter is undefined')->if($asserter->setWith($adapter = new test\adapter()))->then->exception(function () use($asserter) {
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserters\\adapter\\exceptions\\logic')->hasMessage('Call is undefined')->if($asserter->call('md5'))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 3'), $asserter->getCall()))->if($call = new test\adapter\call('md5'))->and($adapter->md5($firstArgument = uniqid()))->then->exception(function () use(&$otherLine, $asserter) {
         $otherLine = __LINE__;
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($firstArgument)))->if($adapter->md5($secondArgument = uniqid()))->then->exception(function () use(&$otherLine, $asserter) {
         $otherLine = __LINE__;
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 2 times instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($firstArgument)) . PHP_EOL . '[2] ' . $call->setArguments(array($secondArgument)))->if($adapter->md5($thirdArgument = uniqid()))->then->object($asserter->thrice())->isIdenticalTo($asserter)->if($adapter->md5($fourthArgument = uniqid()))->then->exception(function () use(&$otherLine, $asserter) {
         $otherLine = __LINE__;
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 4 times instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($firstArgument)) . PHP_EOL . '[2] ' . $call->setArguments(array($secondArgument)) . PHP_EOL . '[3] ' . $call->setArguments(array($thirdArgument)) . PHP_EOL . '[4] ' . $call->setArguments(array($fourthArgument)))->if($adapter->resetCalls())->and($asserter->withArguments($arg = uniqid()))->and($adapter->md5($arg))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($arg)))->if($asserter->withArguments(uniqid()))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->thrice();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($arg)));
 }