refactor: remove status_code from response classes and update related tests
Some checks failed
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m5s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Failing after 2m56s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 3m12s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 3m32s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m17s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m42s

This commit is contained in:
2025-12-10 08:45:51 -05:00
parent f59dcb2dcc
commit 84c3b392ba
9 changed files with 27 additions and 22 deletions

View File

@@ -12,7 +12,6 @@ class NotFoundResponseTest extends Unit
$response = new NotFoundResponse('/api/resource', ['key' => 'value']);
$expected = [
'status_code' => 404,
'message' => 'The requested resource /api/resource was not found.',
'context' => ['key' => 'value'],
];

View File

@@ -19,7 +19,7 @@ class ServerErrorResponseTest extends Unit
$response = new ServerErrorResponse($e, ['operation' => 'data_processing']);
$expected = [
'status_code' => 500,
'code' => 500,
'message' => 'A Test Error occurred.',
'context' => [
'operation' => 'data_processing'
@@ -35,13 +35,15 @@ class ServerErrorResponseTest extends Unit
public function testToArrayNotInDevMode(): void
{
Config::set('app.dev_mode', false);
try {
throw new \Exception('A Test Error occurred.');
} catch (\Exception $exception) {
$response = new ServerErrorResponse($exception);
$expected = [
'status_code' => 500,
'code' => 500,
'message' => 'An internal server error occurred.',
];
@@ -51,13 +53,15 @@ class ServerErrorResponseTest extends Unit
public function testToArrayIfCodeIsSet(): void
{
Config::set('app.dev_mode', false);
try {
throw new \Exception('A Test Error occurred.', 1234);
} catch (\Exception $exception) {
$response = new ServerErrorResponse($exception);
$expected = [
'status_code' => 1234,
'code' => 1234,
'message' => 'An internal server error occurred.',
];
@@ -75,7 +79,7 @@ class ServerErrorResponseTest extends Unit
$response = new ServerErrorResponse($exception);
$expected = [
'status_code' => 1234,
'code' => 1234,
'message' => 'A Test Error occurred.',
'file' => $exception->getFile(),
'line' => $exception->getLine(),