protected function callIsSet() { try { return parent::callIsSet(); } catch (adapter\exceptions\logic $exception) { throw new mock\exceptions\logic('Call is undefined'); } }
public function testNever() { $this->if($asserter = new asserters\adapter($generator = new asserter\generator()))->then->exception(function () use($asserter) { $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Adapter is undefined')->if($asserter->setWith($adapter = new test\adapter()))->then->exception(function () use($asserter) { $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Called function is undefined')->if($call = new php\call('md5'))->and($asserter->call('md5'))->then->object($asserter->never())->isIdenticalTo($asserter)->if($adapter->md5($usedArg = uniqid()))->then->exception(function () use(&$line, $asserter) { $line = __LINE__; $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 1 time instead of 0'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))->if($adapter->resetCalls())->and($asserter->withArguments($arg = uniqid()))->then->object($asserter->never())->isIdenticalTo($asserter)->if($adapter->md5($arg))->then->exception(function () use(&$line, $asserter) { $line = __LINE__; $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 1 time instead of 0'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($arg)))->if($adapter->md5($arg))->then->exception(function () use(&$otherLine, $asserter) { $otherLine = __LINE__; $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('function %s is called 2 times instead of 0'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($arg)) . PHP_EOL . '[2] ' . $call->setArguments(array($arg)))->if($asserter->withArguments(uniqid()))->then->object($asserter->never())->isIdenticalTo($asserter); }
public function testAfter() { $this->if($asserter = new sut($generator = new atoum\asserter\generator()))->and($adapter = new test\adapter())->and($adapter->shouldBeCallafter = uniqid())->and($asserter->setWith($adapter))->and($afterAsserter = new sut(new atoum\asserter\generator()))->and($afterAdapter = new test\adapter())->and($afterAdapter->wasCalledBefore = uniqid())->and($afterAsserter->setWith($afterAdapter))->and($asserter->call('shouldBeCallAfter')->after($afterAsserter->call('wasCalledBefore')))->and($afterAdapter->wasCalledBefore())->and($adapter->shouldBeCallAfter())->then->object($asserter->once())->isIdenticalTo($asserter)->if($adapter->resetCalls())->and($afterAdapter->resetCalls())->and($adapter->shouldBeCallAfter())->and($afterAdapter->wasCalledBefore())->then->exception(function () use($asserter) { $asserter->once(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not called after %s'), $asserter->getCall(), $afterAsserter->getCall()))->if($adapter->resetCalls())->and($afterAdapter->resetCalls())->and($adapter->shouldBeCallAfter())->and($adapter->shouldBeCallAfter())->and($afterAdapter->wasCalledBefore())->then->exception(function () use($asserter) { $asserter->once(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not called after %s'), $asserter->getCall(), $afterAsserter->getCall()))->if($adapter->resetCalls())->and($afterAdapter->resetCalls())->and($adapter->shouldBeCallAfter())->and($afterAdapter->wasCalledBefore())->and($adapter->shouldBeCallAfter())->then->exception(function () use($asserter) { $asserter->once(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not called after %s'), $asserter->getCall(), $afterAsserter->getCall()))->if($adapter->resetCalls())->and($afterAdapter->resetCalls())->and($afterAdapter->wasCalledBefore())->and($adapter->shouldBeCallAfter())->and($afterAdapter->wasCalledBefore())->then->object($asserter->once())->isIdenticalTo($asserter)->if($adapter->resetCalls())->and($afterAdapter->resetCalls())->and($afterAdapter->wasCalledBefore())->and($adapter->shouldBeCallAfter())->and($afterAdapter->wasCalledBefore())->and($adapter->shouldBeCallAfter())->then->object($asserter->twice())->isIdenticalTo($asserter)->if($adapter->resetCalls())->and($afterAdapter->resetCalls())->and($afterAdapter->wasCalledBefore())->and($adapter->shouldBeCallAfter())->and($adapter->shouldBeCallAfter())->and($afterAdapter->wasCalledBefore())->then->object($asserter->twice())->isIdenticalTo($asserter)->if($adapter->resetCalls())->and($afterAdapter->resetCalls())->and($afterAdapter->wasCalledBefore())->and($afterAdapter->wasCalledBefore())->and($adapter->shouldBeCallAfter())->then->object($asserter->once())->isIdenticalTo($asserter); }