/** * @test */ public function outDoesNotGetCalledIfGivenAndErrorHandlerIsSetAndErrorOccurs() { $expected = ['errCalled']; $called = []; $resolver = $this->createMock(ActionResolver::class); $resolver->expects($this->once())->method('resolve')->will($this->returnValue(function () { throw new \Exception(); })); $app = new Adrenaline([$resolver], [], null, $this->emitter); $app->setErrorHandler(function (ServerRequestInterface $request, ResponseInterface $response, $err) use(&$called) { $called[] = 'errCalled'; return $response; }); $app($this->request, $this->response, function (ServerRequestInterface $request, ResponseInterface $response) use(&$called) { $called[] = 'outCalled'; return $response; }); $this->assertSame($expected, $called); }
/** * @Bean * @return \bitExpert\Adrenaline\Adrenaline */ public function webapp() { $app = new Adrenaline([$this->containerActionResolver()], [$this->containerResponderResolver()], $this->router()); $app->beforeResolveAction(new PageNotFoundMiddleware()); return $app; }