示例#1
0
 public function testAtLeastOnce()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->atLeastOnce();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Mock is undefined')->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))->then->exception(function () use($asserter) {
         $asserter->atLeastOnce();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Call is undefined')->if($asserter->call('foo'))->then->exception(function () use($asserter) {
         $asserter->atLeastOnce();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time'), $asserter->getCall()))->if($mock->foo(uniqid()))->then->object($asserter->atLeastOnce())->isIdenticalTo($asserter)->if($mock->foo(uniqid()))->then->object($asserter->atLeastOnce())->isIdenticalTo($asserter)->if($mock->getMockController()->resetCalls())->and($asserter->withArguments($usedArg = uniqid()))->then->exception(function () use($asserter) {
         $asserter->atLeastOnce();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time'), $asserter->getCall()))->if($call = new test\adapter\call('foo', null, new decorators\addClass($mock)))->if($mock->foo($usedArg))->then->object($asserter->atLeastOnce())->isIdenticalTo($asserter)->if($asserter->withArguments($otherArg = uniqid()))->then->exception(function () use($asserter) {
         $asserter->atLeastOnce();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)));
 }