Exemple #1
0
 public function testExactly()
 {
     $this->if($asserter = new asserters\adapter($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Adapter is undefined')->if($asserter->setWith($adapter = new test\adapter()))->then->exception(function () use($asserter) {
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Called function is undefined')->if($asserter->call('md5'))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 0 time instead of 2'), $asserter->getCall()))->if($call = new php\call('md5'))->and($adapter->md5($arg = uniqid()))->then->exception(function () use(&$otherLine, $asserter) {
         $otherLine = __LINE__;
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 1 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($arg)))->if($adapter->md5($otherArg = uniqid()))->then->object($asserter->exactly(2))->isIdenticalTo($asserter)->if($adapter->md5($anOtherArg = uniqid()))->then->exception(function () use(&$anotherLine, $asserter) {
         $anotherLine = __LINE__;
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 3 times instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($arg)) . PHP_EOL . '[2] ' . $call->setArguments(array($otherArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($anOtherArg)))->if($adapter->resetCalls())->and($asserter->withArguments($arg = uniqid()))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 0 time instead of 2'), $asserter->getCall()))->if($adapter->md5($usedArg = uniqid()))->then->exception(function () use(&$otherLine, $asserter) {
         $otherLine = __LINE__;
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 0 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))->if($adapter->md5($arg))->then->exception(function () use(&$anotherLine, $asserter) {
         $anotherLine = __LINE__;
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 1 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($arg)))->if($adapter->md5($arg))->then->object($asserter->exactly(2))->isIdenticalTo($asserter)->if($adapter->md5($arg))->then->exception(function () use(&$anAnotherLine, $asserter) {
         $anAnotherLine = __LINE__;
         $asserter->exactly(2);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 3 times instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($arg)) . PHP_EOL . '[3] ' . $call->setArguments(array($arg)) . PHP_EOL . '[4] ' . $call->setArguments(array($arg)));
 }