'data_processing']); $expected = [ 'status_code' => 500, 'message' => 'A Test Error occurred.', 'context' => [ 'operation' => 'data_processing' ], 'file' => '/app/tests/Http/Responses/ServerErrorResponseTest.php', 'line' => $e->getLine(), 'trace' => $e->getTrace(), ]; $this->assertEquals($expected, $response->toArray()); } } public function testToArrayNotInDevMode(): void { try { throw new \Exception('A Test Error occurred.'); } catch (\Exception $exception) { $response = new ServerErrorResponse($exception); $expected = [ 'status_code' => 500, 'message' => 'An internal server error occurred.', ]; $this->assertEquals($expected, $response->toArray()); } } public function testToArrayIfCodeIsSet(): void { try { throw new \Exception('A Test Error occurred.', 1234); } catch (\Exception $exception) { $response = new ServerErrorResponse($exception); $expected = [ 'status_code' => 1234, 'message' => 'An internal server error occurred.', ]; $this->assertEquals($expected, $response->toArray()); } } public function testToArrayIfCodeIsSetDevMode(): void { Config::set('app.dev_mode', true); try { throw new \Exception('A Test Error occurred.', 1234); } catch (\Exception $exception) { $response = new ServerErrorResponse($exception); $expected = [ 'status_code' => 1234, 'message' => 'A Test Error occurred.', 'file' => '/app/tests/Http/Responses/ServerErrorResponseTest.php', 'line' => $exception->getLine(), 'trace' => $exception->getTrace(), 'context' => [], ]; $this->assertEquals($expected, $response->toArray()); } } }