setDecorator() public method

public setDecorator ( mageekguy\atoum\test\adapter\call\decorator $decorator = null )
$decorator mageekguy\atoum\test\adapter\call\decorator
Beispiel #1
0
 public function testSetDecorator()
 {
     $this->if($call = new testedClass())->then->object($call->setDecorator($decorator = new decorator()))->isIdenticalTo($call)->object($call->getDecorator())->isIdenticalTo($decorator)->object($call->setDecorator())->isIdenticalTo($call)->object($call->getDecorator())->isNotIdenticalTo($decorator)->isEqualTo(new decorator());
 }
Beispiel #2
0
 public function testOnce()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->once();
     })->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->once();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Call is undefined')->if($asserter->call('foo'))->then->exception(function () use($asserter) {
         $asserter->once();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 1'), $asserter->getCall()))->if($call = new test\adapter\call('foo', null, new decorators\addClass($mock->getMockController()->getMockClass())))->and($call->setDecorator(new decorators\addClass($mock)))->and($mock->foo($usedArg = uniqid()))->then->object($asserter->once())->isIdenticalTo($asserter)->if($mock->foo($otherUsedArg = uniqid()))->then->exception(function () use($asserter) {
         $asserter->once();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 2 times instead of 1'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($otherUsedArg)))->if($mock->getMockController()->resetCalls())->and($asserter->withArguments($usedArg = uniqid()))->and($mock->foo($usedArg))->then->object($asserter->once())->isIdenticalTo($asserter)->if($asserter->withArguments($arg = uniqid()))->then->exception(function () use($asserter) {
         $asserter->once();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 1'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)));
 }