public function decorate(php\call $call) { $string = $call->getFunction() . '(' . $this->argumentsDecorator->decorate($call->getArguments()) . ')'; $object = $call->getObject(); if ($object !== null) { $string = get_class($object) . '::' . $string; } return $string; }
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 withArguments() { return parent::setArguments(func_get_args()); }
public function testNever() { $this->if($asserter = new asserters\mock($generator = new asserter\generator()))->then->exception(function () use($asserter) { $asserter->never(); })->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->never(); })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Called method is undefined')->if($asserter->call('foo'))->then->object($asserter->never())->isIdenticalTo($asserter)->if($call = new php\call('foo', null, $mock))->and($mock->foo($usedArg = uniqid()))->then->exception(function () use($asserter) { $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('method %s is called 1 time instead of 0'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))->if($mock->getMockController()->resetCalls())->and($asserter->withArguments($arg = uniqid()))->then->object($asserter->never())->isIdenticalTo($asserter)->if($mock->foo($arg))->then->exception(function () use($asserter) { $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('method %s is called 1 time instead of 0'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($arg)))->if($mock->foo($arg))->then->exception(function () use($asserter) { $asserter->never(); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('method %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($mock->foo($arg))->then->exception(function () use($asserter, &$message) { $asserter->never($message = uniqid()); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage($message)->if($asserter->withArguments(uniqid()))->then->object($asserter->never())->isIdenticalTo($asserter); }