public function testGetLastCall() { $this->if($call = new call\mock(new asserters\adapter(new asserter\generator()), $mock = new \mock\dummy(), 'foo'))->then->variable($call->getLastCall())->isNull()->when(function () { $otherMock = new \mock\dummy(); $otherMock->foo(); })->variable($call->getLastCall())->isNull()->when(function () use($mock) { $mock->foo(); })->integer($call->getLastCall())->isEqualTo(2)->when(function () use($mock) { $mock->foo(); })->integer($call->getLastCall())->isEqualTo(3); }
public function should_invoke_method_on_provided_object_and_return_exception_asserter_when_asserting_on_thrown_exception() { $this->given($generator = new atoum\asserter\generator(), $phpClass = new \mock\mageekguy\atoum\asserters\phpClass($generator), $test = new \mock\mageekguy\atoum\test(), $object = new \mock\dummy(), $object->getMockController()->disableMethodChecking(), $method = uniqid('A'), $this->calling($phpClass)->hasMethod = $phpClass, $this->calling($object)->{$method}->throw = $exception = new \exception(), $this->calling($test)->getTestedClassName = $testedClassName = get_class($object), $exceptionAsserter = new atoum\asserters\exception($generator))->if($this->newTestedInstance($generator, $phpClass), $this->testedInstance->setWithTest($test)->setMethod($method))->then->invoking('setInstance', $object)->shouldReturn->object->isTestedInstance->invoking('throws')->shouldReturn->object->isEqualTo($exceptionAsserter->setWith($exception))->mock($object)->call($method)->once(); }