public function testClosureIsSet() { $invoker = new adapter\invoker(); $this->assert->exception(function () use($invoker) { $invoker->closureIsSetForCall(-rand(1, PHP_INT_MAX), function () { }); })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic\\invalidArgument')->hasMessage('Call number must be greater than or equal to zero')->boolean($invoker->closureIsSetForCall(rand(0, PHP_INT_MAX)))->isFalse(); $invoker->setClosure(function () { }, 0); $this->assert->boolean($invoker->closureIsSetForCall())->isTrue()->boolean($invoker->closureIsSetForCall(0))->isTrue()->boolean($invoker->closureIsSetForCall(rand(1, PHP_INT_MAX)))->isFalse(); }
public function testOffsetUnset() { $this->if($invoker = new testedClass(uniqid()))->then->exception(function () use($invoker) { $invoker->offsetUnset(-rand(1, PHP_INT_MAX), function () { }); })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic\\invalidArgument')->hasMessage('Call number must be greater than or equal to zero')->exception(function () use($invoker, &$call) { $invoker->offsetUnset($call = rand(0, PHP_INT_MAX), function () { }); })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic\\invalidArgument')->hasMessage('There is no closure defined for call ' . $call)->if($invoker->setClosure(function () { }))->then->boolean($invoker->closureIsSetForCall(0))->isTrue()->object($invoker->offsetUnset(0))->isIdenticalTo($invoker)->boolean($invoker->closureIsSetForCall(0))->isFalse(); }