diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index 810108e..e5a0d35 100644 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -60,6 +60,7 @@ public function render($request, Exception $e) $response = $this->exceptionHandler->render($request, $e); if ($this->shouldRenderException($response) === true) { + $_SERVER = $request->server(); $response->setContent( $this->debuggerManager->exceptionHandler($e) ); diff --git a/tests/Exceptions/HandlerTest.php b/tests/Exceptions/HandlerTest.php index 3608485..8132620 100644 --- a/tests/Exceptions/HandlerTest.php +++ b/tests/Exceptions/HandlerTest.php @@ -4,6 +4,7 @@ use Exception; use Mockery as m; +use Illuminate\Http\Request; use Illuminate\Http\Response; use PHPUnit\Framework\TestCase; use Recca0120\LaravelTracy\Exceptions\Handler; @@ -170,17 +171,19 @@ public function testRender() $exceptionHandler->shouldReceive('render') ->once() ->with( - $request = m::mock('Illuminate\Http\Request'), + $request = Request::capture(), $exception = new Exception() )->andReturn( $response = m::mock('Symfony\Component\HttpFoundation\Response') ); $response->shouldReceive('getContent')->once()->andReturn(null); - $debuggerManager->shouldReceive('exceptionHandler')->once()->with($exception)->andReturn($content = 'foo'); $response->shouldReceive('setContent')->once()->with($content); + $_SERVER['foo'] = 'bar'; + $this->assertSame($response, $handler->render($request, $exception)); + $this->assertSame($_SERVER, $request->server()); } public function testRenderForConsoleMethod()