Best Atoum code snippet using mock.fooWithSeveralArguments
mock.php
Source:mock.php
...12class dummy13{14 public function foo($arg) {}15 public function bar($arg) {}16 public function fooWithSeveralArguments($arg1, $arg2, $arg3, $arg4, $arg5) {}17}18class mock extends atoum\test19{20 public function testClass()21 {22 $this->testedClass->isSubclassOf('mageekguy\atoum\asserter');23 }24 public function test__construct()25 {26 $this27 ->if($asserter = new sut($generator = new asserter\generator()))28 ->then29 ->object($asserter->getLocale())->isIdenticalTo($generator->getLocale())30 ->object($asserter->getGenerator())->isIdenticalTo($generator)31 ->variable($asserter->getAdapter())->isNull()32 ->variable($asserter->getCall())->isEqualTo(new test\adapter\call())33 ;34 }35 public function testReset()36 {37 $this38 ->if($mockController = new \mock\mageekguy\atoum\mock\controller())39 ->and($asserter = new sut($generator = new asserter\generator()))40 ->then41 ->variable($asserter->getAdapter())->isNull()42 ->object($asserter->reset())->isIdenticalTo($asserter)43 ->variable($asserter->getAdapter())->isNull()44 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\score()))45 ->and($mock->setMockController($mockController))46 ->and($this->resetMock($mockController))47 ->then48 ->object($asserter->getAdapter())->isIdenticalTo($mock->getMockController())49 ->object($asserter->reset())->isIdenticalTo($asserter)50 ->object($asserter->getAdapter())->isIdenticalTo($mock->getMockController())51 ->mock($mockController)->call('resetCalls')->once();52 }53 public function testSetWith()54 {55 $this56 ->if($asserter = new sut($generator = new asserter\generator()))57 ->and($adapter = new atoum\test\adapter())58 ->and($adapter->class_exists = true)59 ->then60 ->exception(function() use ($asserter, & $mock) { $asserter->setWith($mock = uniqid()); })61 ->isInstanceOf('mageekguy\atoum\asserter\exception')62 ->hasMessage(sprintf($generator->getLocale()->_('%s is not a mock'), $asserter->getTypeOf($mock)))63 ->object($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\mock($adapter)))->isIdenticalTo($asserter)64 ->object($asserter->getAdapter())->isIdenticalTo($mock->getMockController())65 ;66 }67 public function testWasCalled()68 {69 $this70 ->if($asserter = new sut($generator = new asserter\generator()))71 ->then72 ->exception(function() use ($asserter) { $asserter->wasCalled(); })73 ->isInstanceOf('mageekguy\atoum\exceptions\logic')74 ->hasMessage('Mock is undefined')75 ->if($adapter = new atoum\test\adapter())76 ->and($adapter->class_exists = true)77 ->and($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\mock($adapter)))78 ->and($mock->getMockController()->resetCalls())79 ->then80 ->exception(function() use ($asserter) { $asserter->wasCalled(); })81 ->isInstanceOf('mageekguy\atoum\asserter\exception')82 ->hasMessage(sprintf($generator->getLocale()->_('%s is not called'), get_class($mock)))83 ->exception(function() use ($asserter, & $failMessage) { $asserter->wasCalled($failMessage = uniqid()); })84 ->isInstanceOf('mageekguy\atoum\asserter\exception')85 ->hasMessage($failMessage)86 ->if($mock->getMockController()->{$method = __FUNCTION__} = function() {})87 ->and($mock->{$method}())88 ->then89 ->object($asserter->wasCalled())->isIdenticalTo($asserter)90 ;91 }92 public function testWasNotCalled()93 {94 $this95 ->if($asserter = new sut($generator = new asserter\generator()))96 ->then97 ->exception(function() use ($asserter) { $asserter->wasNotCalled(); })98 ->isInstanceOf('mageekguy\atoum\exceptions\logic')99 ->hasMessage('Mock is undefined')100 ->if($adapter = new atoum\test\adapter())101 ->and($adapter->class_exists = true)102 ->and($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\mock($adapter)))103 ->and($mock->getMockController()->resetCalls())104 ->then105 ->object($asserter->wasNotCalled())->isIdenticalTo($asserter)106 ->if($mock->getMockController()->{$method = __FUNCTION__} = function() {})107 ->and($mock->{$method}())108 ->then109 ->exception(function() use ($asserter, & $failMessage) { $asserter->wasNotCalled($failMessage = uniqid()); })110 ->isInstanceOf('mageekguy\atoum\asserter\exception')111 ->hasMessage($failMessage)112 ;113 }114 public function testCall()115 {116 $this117 ->mockGenerator->orphanize('asserterFail')118 ->if($asserter = new sut(new \mock\mageekguy\atoum\asserter\generator()))119 ->then120 ->exception(function() use ($asserter) { $asserter->call(uniqid()); })121 ->isInstanceOf('mageekguy\atoum\exceptions\logic')122 ->hasMessage('Mock is undefined')123 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))124 ->then125 ->object($asserter->call($function = uniqid()))->isIdenticalTo($asserter)126 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mock->getMockController()->getMockClass())))127 ->if($asserter->withArguments())128 ->then129 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, array(), new decorators\addClass($mock->getMockController()->getMockClass())))130 ->object($asserter->disableEvaluationChecking()->call($function = uniqid()))->isIdenticalTo($asserter)131 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mock->getMockController()->getMockClass())))132 ;133 }134 public function testWithArguments()135 {136 $this137 ->mockGenerator->orphanize('asserterFail')138 ->if($asserter = new sut(new \mock\mageekguy\atoum\asserter\generator()))139 ->then140 ->exception(function() use ($asserter) { $asserter->withArguments(uniqid()); })141 ->isInstanceOf('mageekguy\atoum\exceptions\logic')142 ->hasMessage('Mock is undefined')143 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))144 ->then145 ->exception(function() use ($asserter) { $asserter->withArguments(uniqid()); })146 ->isInstanceOf('mageekguy\atoum\exceptions\logic')147 ->hasMessage('Call is undefined')148 ->if($asserter->call($function = uniqid()))149 ->then150 ->object($asserter->withArguments())->isIdenticalTo($asserter)151 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, array(), new decorators\addClass($mock)))152 ->object($asserter->withArguments($arg1 = uniqid()))->isIdenticalTo($asserter)153 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, array($arg1), new decorators\addClass($mock)))154 ->object($asserter->disableEvaluationChecking()->withArguments($arg1 = uniqid(), $arg2 = uniqid()))->isIdenticalTo($asserter)155 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, array($arg1, $arg2), new decorators\addClass($mock)))156 ;157 }158 public function testWithAtLeastArguments()159 {160 $this161 ->mockGenerator->orphanize('asserterFail')162 ->if($asserter = new sut(new \mock\mageekguy\atoum\asserter\generator()))163 ->then164 ->exception(function() use ($asserter) { $asserter->withArguments(uniqid()); })165 ->isInstanceOf('mageekguy\atoum\exceptions\logic')166 ->hasMessage('Mock is undefined')167 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))168 ->then169 ->exception(function() use ($asserter) { $asserter->withArguments(uniqid()); })170 ->isInstanceOf('mageekguy\atoum\exceptions\logic')171 ->hasMessage('Call is undefined')172 ->if($asserter->call($function = uniqid()))173 ->then174 ->object($asserter->withAtLeastArguments($arguments = array(1 => uniqid())))->isIdenticalTo($asserter)175 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, $arguments, new decorators\addClass($mock)))176 ->object($asserter->disableEvaluationChecking()->withAtLeastArguments($arguments = array(2 => uniqid(), 5 => uniqid())))->isIdenticalTo($asserter)177 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, $arguments, new decorators\addClass($mock)))178 ;179 }180 public function testWithAnyArguments()181 {182 $this183 ->mockGenerator->orphanize('asserterFail')184 ->if($asserter = new sut(new \mock\mageekguy\atoum\asserter\generator()))185 ->then186 ->exception(function() use ($asserter) { $asserter->withArguments(uniqid()); })187 ->isInstanceOf('mageekguy\atoum\exceptions\logic')188 ->hasMessage('Mock is undefined')189 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))190 ->then191 ->exception(function() use ($asserter) { $asserter->withArguments(uniqid()); })192 ->isInstanceOf('mageekguy\atoum\exceptions\logic')193 ->hasMessage('Call is undefined')194 ->if($asserter->call($function = uniqid()))195 ->then196 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mock)))197 ->object($asserter->withAnyArguments())->isIdenticalTo($asserter)198 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mock)))199 ->if($asserter->disableEvaluationChecking()->withArguments($arg = uniqid()))200 ->then201 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, array($arg), new decorators\addClass($mock)))202 ->object($asserter->withAnyArguments())->isIdenticalTo($asserter)203 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, null, new decorators\addClass($mock)))204 ;205 }206 public function testWithoutAnyArgument()207 {208 $this209 ->mockGenerator->orphanize('asserterFail')210 ->if($asserter = new sut(new \mock\mageekguy\atoum\asserter\generator()))211 ->then212 ->exception(function() use ($asserter) { $asserter->withoutAnyArgument(); })213 ->isInstanceOf('mageekguy\atoum\exceptions\logic')214 ->hasMessage('Mock is undefined')215 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))216 ->then217 ->exception(function() use ($asserter) { $asserter->withoutAnyArgument(); })218 ->isInstanceOf('mageekguy\atoum\exceptions\logic')219 ->hasMessage('Call is undefined')220 ->if($asserter->call($function = uniqid()))221 ->then222 ->object($asserter->disableEvaluationChecking()->withoutAnyArgument())->isIdenticalTo($asserter)223 ->object($asserter->getCall())->isEqualTo(new test\adapter\call($function, array(), new decorators\addClass($mock)))224 ;225 }226 public function testOnce()227 {228 $this229 ->if($asserter = new sut($generator = new asserter\generator()))230 ->then231 ->exception(function() use ($asserter) { $asserter->once(); })232 ->isInstanceOf('mageekguy\atoum\exceptions\logic')233 ->hasMessage('Mock is undefined')234 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))235 ->then236 ->exception(function() use ($asserter) { $asserter->once(); })237 ->isInstanceOf('mageekguy\atoum\exceptions\logic')238 ->hasMessage('Call is undefined')239 ->if($asserter->call('foo'))240 ->then241 ->exception(function() use ($asserter) { $asserter->once(); })242 ->isInstanceOf('mageekguy\atoum\asserter\exception')243 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 1'), $asserter->getCall()))244 ->if($call = new test\adapter\call('foo', null, new decorators\addClass($mock->getMockController()->getMockClass())))245 ->and($call->setDecorator(new decorators\addClass($mock)))246 ->and($mock->foo($usedArg = uniqid()))247 ->then248 ->object($asserter->once())->isIdenticalTo($asserter)249 ->if($mock->foo($otherUsedArg = uniqid()))250 ->then251 ->exception(function() use ($asserter) { $asserter->once(); })252 ->isInstanceOf('mageekguy\atoum\asserter\exception')253 ->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)))254 ->if($mock->getMockController()->resetCalls())255 ->and($asserter->withArguments($usedArg = uniqid()))256 ->and($mock->foo($usedArg))257 ->then258 ->object($asserter->once())->isIdenticalTo($asserter)259 ->if($asserter->withArguments($arg = uniqid()))260 ->then261 ->exception(function() use ($asserter) { $asserter->once(); })262 ->isInstanceOf('mageekguy\atoum\asserter\exception')263 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 1'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))264 ;265 }266 public function testTwice()267 {268 $this269 ->if($asserter = new sut($generator = new asserter\generator()))270 ->then271 ->exception(function() use ($asserter) { $asserter->twice(); })272 ->isInstanceOf('mageekguy\atoum\exceptions\logic')273 ->hasMessage('Mock is undefined')274 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))275 ->then276 ->exception(function() use ($asserter) { $asserter->twice(); })277 ->isInstanceOf('mageekguy\atoum\exceptions\logic')278 ->hasMessage('Call is undefined')279 ->if($asserter->call('foo'))280 ->then281 ->exception(function() use ($asserter) { $asserter->twice(); })282 ->isInstanceOf('mageekguy\atoum\asserter\exception')283 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 2'), $asserter->getCall()))284 ->if($call = new test\adapter\call('foo', null, new decorators\addClass($mock)))285 ->and($mock->foo($usedArg = uniqid()))286 ->then287 ->exception(function() use ($asserter) { $asserter->twice(); })288 ->isInstanceOf('mageekguy\atoum\asserter\exception')289 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))290 ->if($mock->foo($secondArg = uniqid()))291 ->then292 ->object($asserter->twice())->isIdenticalTo($asserter)293 ->if($mock->foo($thirdArg = uniqid()))294 ->then295 ->exception(function() use ($asserter) { $asserter->twice(); })296 ->isInstanceOf('mageekguy\atoum\asserter\exception')297 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 3 times instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($secondArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($thirdArg)))298 ->if($mock->getMockController()->resetCalls())299 ->and($asserter->withArguments($usedArg = uniqid()))300 ->then301 ->exception(function() use ($asserter) { $asserter->twice(); })302 ->isInstanceOf('mageekguy\atoum\asserter\exception')303 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 2'), $asserter->getCall()))304 ->if($mock->foo($usedArg))305 ->then306 ->exception(function() use ($asserter) { $asserter->twice(); })307 ->isInstanceOf('mageekguy\atoum\asserter\exception')308 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))309 ->if($mock->foo($usedArg))310 ->then311 ->object($asserter->twice())->isIdenticalTo($asserter)312 ->if($mock->foo($usedArg))313 ->then314 ->exception(function() use ($asserter) { $asserter->twice(); })315 ->isInstanceOf('mageekguy\atoum\asserter\exception')316 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 3 times instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($usedArg)))317 ->if($asserter->withArguments($arg = uniqid()))318 ->then319 ->exception(function() use ($asserter) { $asserter->twice(); })320 ->isInstanceOf('mageekguy\atoum\asserter\exception')321 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($usedArg)))322 ;323 }324 public function testThrice()325 {326 $this327 ->if($asserter = new sut($generator = new asserter\generator()))328 ->then329 ->exception(function() use ($asserter) { $asserter->thrice(); })330 ->isInstanceOf('mageekguy\atoum\exceptions\logic')331 ->hasMessage('Mock is undefined')332 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))333 ->then334 ->exception(function() use ($asserter) { $asserter->thrice(); })335 ->isInstanceOf('mageekguy\atoum\exceptions\logic')336 ->hasMessage('Call is undefined')337 ->if($asserter->call('foo'))338 ->then339 ->exception(function() use ($asserter) { $asserter->thrice(); })340 ->isInstanceOf('mageekguy\atoum\asserter\exception')341 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 3'), $asserter->getCall()))342 ->if($call = new test\adapter\call('foo', null, new decorators\addClass($mock)))343 ->and($mock->foo($usedArg = uniqid()))344 ->then345 ->exception(function() use ($asserter) { $asserter->thrice(); })346 ->isInstanceOf('mageekguy\atoum\asserter\exception')347 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))348 ->if($mock->foo($secondArg = uniqid()))349 ->then350 ->exception(function() use ($asserter) { $asserter->thrice(); })351 ->isInstanceOf('mageekguy\atoum\asserter\exception')352 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 2 times instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($secondArg)))353 ->if($mock->foo($thirdArg = uniqid()))354 ->then355 ->object($asserter->thrice())->isIdenticalTo($asserter)356 ->if($mock->foo($fourthArg = uniqid()))357 ->then358 ->exception(function() use ($asserter) { $asserter->thrice(); })359 ->isInstanceOf('mageekguy\atoum\asserter\exception')360 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 4 times instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($secondArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($thirdArg)) . PHP_EOL . '[4] ' . $call->setArguments(array($fourthArg)))361 ->if($mock->getMockController()->resetCalls())362 ->and($asserter->withArguments($usedArg = uniqid()))363 ->then364 ->exception(function() use ($asserter) { $asserter->thrice(); })365 ->isInstanceOf('mageekguy\atoum\asserter\exception')366 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 3'), $asserter->getCall()))367 ->if($mock->foo($usedArg))368 ->then369 ->exception(function() use ($asserter) { $asserter->thrice(); })370 ->isInstanceOf('mageekguy\atoum\asserter\exception')371 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))372 ->if($mock->foo($usedArg))373 ->then374 ->exception(function() use ($asserter) { $asserter->thrice(); })375 ->isInstanceOf('mageekguy\atoum\asserter\exception')376 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 2 times instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($usedArg)))377 ->if($mock->foo($usedArg))378 ->then379 ->object($asserter->thrice())->isIdenticalTo($asserter)380 ->if($mock->foo($usedArg))381 ->then382 ->exception(function() use ($asserter) { $asserter->thrice(); })383 ->isInstanceOf('mageekguy\atoum\asserter\exception')384 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 4 times instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[4] ' . $call->setArguments(array($usedArg)))385 ->if($asserter->withArguments($arg = uniqid()))386 ->then387 ->exception(function() use ($asserter) { $asserter->thrice(); })388 ->isInstanceOf('mageekguy\atoum\asserter\exception')389 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 3'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[4] ' . $call->setArguments(array($usedArg)))390 ;391 }392 public function testAtLeastOnce()393 {394 $this395 ->if($asserter = new sut($generator = new asserter\generator()))396 ->then397 ->exception(function() use ($asserter) { $asserter->atLeastOnce(); })398 ->isInstanceOf('mageekguy\atoum\exceptions\logic')399 ->hasMessage('Mock is undefined')400 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))401 ->then402 ->exception(function() use ($asserter) { $asserter->atLeastOnce(); })403 ->isInstanceOf('mageekguy\atoum\exceptions\logic')404 ->hasMessage('Call is undefined')405 ->if($asserter->call('foo'))406 ->then407 ->exception(function() use ($asserter) { $asserter->atLeastOnce(); })408 ->isInstanceOf('mageekguy\atoum\asserter\exception')409 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time'), $asserter->getCall()))410 ->if($mock->foo(uniqid()))411 ->then412 ->object($asserter->atLeastOnce())->isIdenticalTo($asserter)413 ->if($mock->foo(uniqid()))414 ->then415 ->object($asserter->atLeastOnce())->isIdenticalTo($asserter)416 ->if($mock->getMockController()->resetCalls())417 ->and($asserter->withArguments($usedArg = uniqid()))418 ->then419 ->exception(function() use ($asserter) { $asserter->atLeastOnce(); })420 ->isInstanceOf('mageekguy\atoum\asserter\exception')421 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time'), $asserter->getCall()))422 ->if($call = new test\adapter\call('foo', null, new decorators\addClass($mock)))423 ->if( $mock->foo($usedArg))424 ->then425 ->object($asserter->atLeastOnce())->isIdenticalTo($asserter)426 ->if($asserter->withArguments($otherArg = uniqid()))427 ->then428 ->exception(function() use ($asserter) { $asserter->atLeastOnce(); })429 ->isInstanceOf('mageekguy\atoum\asserter\exception')430 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))431 ;432 }433 public function testExactly()434 {435 $this436 ->if($asserter = new sut($generator = new asserter\generator()))437 ->then438 ->exception(function() use ($asserter) { $asserter->exactly(2); })439 ->isInstanceOf('mageekguy\atoum\exceptions\logic')440 ->hasMessage('Mock is undefined')441 ->if($asserter->setWith($mock = new \mock\mageekguy\atoum\tests\units\asserters\dummy()))442 ->then443 ->exception(function() use ($asserter) { $asserter->exactly(2); })444 ->isInstanceOf('mageekguy\atoum\exceptions\logic')445 ->hasMessage('Call is undefined')446 ->if($asserter->call('foo'))447 ->then448 ->exception(function() use ($asserter) { $asserter->exactly(2); })449 ->isInstanceOf('mageekguy\atoum\asserter\exception')450 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 2'), $asserter->getCall()))451 ->if($call = new test\adapter\call('foo', null, new decorators\addClass($mock)))452 ->and($mock->foo($usedArg = uniqid()))453 ->then454 ->exception(function() use ($asserter) { $asserter->exactly(2); })455 ->isInstanceOf('mageekguy\atoum\asserter\exception')456 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))457 ->if($mock->foo($otherUsedArg = uniqid()))458 ->then459 ->object($asserter->exactly(2))->isIdenticalTo($asserter)460 ->if($mock->foo($anOtherUsedArg = uniqid()))461 ->then462 ->exception(function() use ($asserter) { $asserter->exactly(2); })463 ->isInstanceOf('mageekguy\atoum\asserter\exception')464 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 3 times instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($otherUsedArg)) . PHP_EOL . '[3] ' . $call->setArguments(array($anOtherUsedArg)))465 ->if($mock->getMockController()->resetCalls())466 ->and($asserter->withArguments($arg = uniqid()))467 ->then468 ->exception(function() use ($asserter) { $asserter->exactly(2); })469 ->isInstanceOf('mageekguy\atoum\asserter\exception')470 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 2'), $asserter->getCall()))471 ->if($mock->foo($usedArg = uniqid()))472 ->then473 ->exception(function() use ($asserter) { $asserter->exactly(2); })474 ->isInstanceOf('mageekguy\atoum\asserter\exception')475 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)))476 ->if($mock->foo($arg))477 ->then478 ->exception(function() use ($asserter) { $asserter->exactly(2); })479 ->isInstanceOf('mageekguy\atoum\asserter\exception')480 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 2'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array($usedArg)) . PHP_EOL . '[2] ' . $call->setArguments(array($arg)))481 ->if($mock->foo($arg))482 ->then483 ->object($asserter->exactly(2))->isIdenticalTo($asserter)484 ->if($mock->foo($arg))485 ->then486 ->exception(function() use ($asserter) { $asserter->exactly(2); })487 ->isInstanceOf('mageekguy\atoum\asserter\exception')488 ->hasMessage(sprintf($generator->getLocale()->_('%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)))489 ->if($call = new test\adapter\call('fooWithSeveralArguments', null, new decorators\addClass($mock)))490 ->and($asserter->call('fooWithSeveralArguments'))491 ->then492 ->object($asserter->exactly(0))->isIdenticalTo($asserter)493 ->exception(function() use ($asserter) { $asserter->exactly(1); })494 ->isInstanceOf('mageekguy\atoum\asserter\exception')495 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 0 time instead of 1'), $asserter->getCall()))496 ->if($mock->fooWithSeveralArguments(1, 2, 3, 4, 5))497 ->then498 ->exception(function() use ($asserter) { $asserter->exactly(0); })499 ->isInstanceOf('mageekguy\atoum\asserter\exception')500 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 0'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array(1, 2, 3, 4, 5)))501 ->object($asserter->exactly(1))->isIdenticalTo($asserter)502 ->object($asserter->withArguments(1, 2, 3, 4, 5)->exactly(1))->isIdenticalTo($asserter)503 ->object($asserter->withAtLeastArguments(array(1 => 2, 3 => 4))->exactly(1))->isIdenticalTo($asserter)504 ->object($asserter->withAtLeastArguments(array(1 => 2, 3 => rand(6, PHP_INT_MAX)))->exactly(0))->isIdenticalTo($asserter)505 ->exception(function() use ($asserter) { $asserter->withAtLeastArguments(array(1 => 2, 3 => 4))->exactly(0); })506 ->isInstanceOf('mageekguy\atoum\asserter\exception')507 ->hasMessage(sprintf($generator->getLocale()->_('%s is called 1 time instead of 0'), $asserter->getCall()) . PHP_EOL . '[1] ' . $call->setArguments(array(1, 2, 3, 4, 5)))508 ->object($asserter->withIdenticalArguments(1, 2, 3, 4, 5)->exactly(1))->isIdenticalTo($asserter)509 ->exception(function() use ($asserter) { $asserter->withAtLeastIdenticalArguments(array(1 => '2', 3 => 4))->exactly(1); })510 ->isInstanceOf('mageekguy\atoum\asserter\exception')...
fooWithSeveralArguments
Using AI Code Generation
1$mock->fooWithSeveralArguments(1,2,3);2$mock->fooWithSeveralArguments(1,2,3);3$mock->fooWithSeveralArguments(1,2,3);4$mock->fooWithSeveralArguments(1,2,3);5$mock->fooWithSeveralArguments(1,2,3);6$mock->fooWithSeveralArguments(1,2,3);7$mock->fooWithSeveralArguments(1,2,3);8$mock->fooWithSeveralArguments(1,2,3);9$mock->fooWithSeveralArguments(1,2,3);10$mock->fooWithSeveralArguments(1,2,3);11$mock->fooWithSeveralArguments(1,2,3);12$mock->fooWithSeveralArguments(1,2,3);13$mock->fooWithSeveralArguments(1,2,3);14$mock->fooWithSeveralArguments(1,2,3);15$mock->fooWithSeveralArguments(1,2,3);
fooWithSeveralArguments
Using AI Code Generation
1$mock->fooWithSeveralArguments('a', 'b', 'c');2$mock->fooWithSeveralArguments('a', 'b', 'c');3$mock->fooWithSeveralArguments('a', 'b', 'c');4$mock->fooWithSeveralArguments('a', 'b', 'c');5$mock->fooWithSeveralArguments('a', 'b', 'c');6$mock->fooWithSeveralArguments('a', 'b', 'c');7$mock->fooWithSeveralArguments('a', 'b', 'c');8$mock->fooWithSeveralArguments('a', 'b', 'c');9$mock->fooWithSeveralArguments('a', 'b', 'c');10$mock->fooWithSeveralArguments('a', 'b', 'c');11$mock->fooWithSeveralArguments('a', 'b', 'c');12$mock->fooWithSeveralArguments('a', 'b', 'c');13$mock->fooWithSeveralArguments('a', 'b', 'c');14$mock->fooWithSeveralArguments('a', 'b', 'c');
fooWithSeveralArguments
Using AI Code Generation
1$mock->fooWithSeveralArguments(1, 2, 3);2$mock->barWithSeveralArguments(1, 2, 3);3Fatal error: Call to undefined method Mock_Foo::fooWithSeveralArguments() in 1.php on line 44Fatal error: Call to undefined method Mock_Foo::barWithSeveralArguments() in 2.php on line 45$mock->fooWithSeveralArguments(1, 2, 3);6$mock = $this->getMock('Foo', array('barWithSeveralArguments'));7$mock->barWithSeveralArguments(1, 2, 3);
fooWithSeveralArguments
Using AI Code Generation
1$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);2$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);3$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);4$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);5$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);6$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);7$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);8$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);9$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);10$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);11$mock->fooWithSeveralArguments(1, 2, 3, 4, 5, 6);
fooWithSeveralArguments
Using AI Code Generation
1$mock->fooWithSeveralArguments(1, 2, 3);2$mock->fooWithSeveralArguments(1, 2, 3);3$mock->fooWithSeveralArguments(1, 2, 3);4$mock->fooWithSeveralArguments(1, 2, 3);5The following example shows how to use the returnValueMap() method:6$mock = $this->getMock('MyClass', array('fooWithSeveralArguments'));7$returnValueMap = array(8 array(1, 2, 3, 'first'),9 array(1, 2, 3, 'second'),10 array(1, 2, 3, 'third')11);12$mock->expects($this->any())13 ->method('fooWithSeveralArguments')14 ->will($this->returnValueMap($returnValueMap));15$this->assertEquals('first', $mock->fooWithSeveralArguments(1, 2, 3));16$this->assertEquals('second', $mock->fooWithSeveralArguments(1, 2, 3));17$this->assertEquals('third', $mock->fooWithSeveralArguments(1, 2, 3));18$this->assertEquals('third', $mock->fooWithSeveralArguments(1, 2, 3));19The returnValueMap() method is very useful when you need to test that a method is called with several arguments and that the method returns a value depending on the arguments. The following example shows how to use the returnValueMap() method to test that a method is called with several arguments and that the method
fooWithSeveralArguments
Using AI Code Generation
1$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);2$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);3$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);4$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);5$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);6$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);7$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);8$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);9$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);10$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);11$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);12$mock->fooWithSeveralArguments('foo', 'bar', 1, 2, 3);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with fooWithSeveralArguments on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!