/** * {@inheritdoc} */ public function intercept(MethodInvocation $invocation) { $operation = new Callback(function () use($invocation) { return $invocation->proceed(); }); if (null === ($runner = $this->runnerRepository->getRunnerByMethod($invocation->reflection))) { return $operation->call(); } return $runner->run($operation); }
function it_should_return_the_callable_result(Callback $callback) { $callback->call()->willReturn('foo'); $this->run($callback)->shouldReturn('foo'); }
function it_should_call_the_callable(Callback $callback) { $callback->call()->shouldBeCalled(); $callback->setState(Argument::any())->shouldBeCalled(); $this->run($callback); }