public function testExceptionWithHandler() { $_SERVER["REQUEST_URI"] = "/"; $request = Request::createFromGlobals(); $response = new Response("foo"); $callback = function () { throw new \InvalidArgumentException("Failed"); }; $exception = function (\InvalidArgumentException $ex, Request $reqInner) use($request, $response) { $this->assertSame($reqInner, $request); return $response; }; $app = new Application(); $app->get('/', $callback); $app->exception($exception); $actual = $app->handle($request); $this->assertSame($response, $actual); }