Priority: 🟡 Medium
Description
src/Fetch/Enum/Status.php (246 lines) defines 40+ HTTP status codes with associated reason phrases and category classification methods (isSuccess(), isClientError(), etc.). None of these are directly tested — a typo in a reason phrase or a miscategorised status code would be invisible.
For example:
Status::NOT_FOUND->reasonPhrase() should return 'Not Found', not 'Not found' or 'Not Found ' (trailing space)
Status::OK->isSuccess() should return true
Status::INTERNAL_SERVER_ERROR->isServerError() should return true and isSuccess() should return false
Current gap
No StatusTest.php in tests/Unit/.
Recommended Fix
Create tests/Unit/StatusTest.php using PHPUnit's @dataProvider to cover all cases efficiently:
public static function statusCategoryProvider(): array
{
return [
[Status::OK, isSuccess: true, isClientError: false, isServerError: false],
[Status::CREATED, isSuccess: true, isClientError: false, isServerError: false],
[Status::NOT_FOUND, isSuccess: false, isClientError: true, isServerError: false],
[Status::INTERNAL_SERVER_ERROR, isSuccess: false, isClientError: false, isServerError: true],
// ... all 40+ cases
];
}
Also add a test that every defined case has a non-empty reason phrase string.
Related
Issue #90 — MED-2: Status category classification should use range arithmetic
Priority: 🟡 Medium
Description
src/Fetch/Enum/Status.php(246 lines) defines 40+ HTTP status codes with associated reason phrases and category classification methods (isSuccess(),isClientError(), etc.). None of these are directly tested — a typo in a reason phrase or a miscategorised status code would be invisible.For example:
Status::NOT_FOUND->reasonPhrase()should return'Not Found', not'Not found'or'Not Found '(trailing space)Status::OK->isSuccess()should returntrueStatus::INTERNAL_SERVER_ERROR->isServerError()should returntrueandisSuccess()should returnfalseCurrent gap
No
StatusTest.phpintests/Unit/.Recommended Fix
Create
tests/Unit/StatusTest.phpusing PHPUnit's@dataProviderto cover all cases efficiently:Also add a test that every defined case has a non-empty reason phrase string.
Related
Issue #90 — MED-2: Status category classification should use range arithmetic