Skip to content

[TEST] Add parameterized tests for Status enum (40+ reason phrases and category ranges untested) #103

Description

@jeromesinolanka

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs-triageNeeds review before work beginspriority: mediumCode quality, completeness, or maintainabilitytestingTest coverage, fixtures, or testing infrastructure

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions