Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
🟡 Changes recommended
The status-header tests cannot detect a hardcoded HTTP/1.1 regression because the bootstrap uses that same protocol; a different supported protocol must be checked in both the exact header and the fourth filter argument.
1 open issue
What changed in this PR
Adds PHPUnit coverage for WordPress’s status_header() function, using its filter to inspect generated headers without relying on CLI header output.
Changes:
- Tests standard status codes and custom descriptions.
- Checks unknown codes with and without descriptions.
- Adds a server-protocol assertion.
| File | Description |
|---|---|
| tests/phpunit/tests/wp-includes/functions/StatusHeaderTest.php | Adds filter-based tests for status headers, descriptions, unknown codes, and protocol handling. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
lancewillett
left a comment
There was a problem hiding this comment.
The HTTP/2 case now checks both the header string and the protocol passed to the filter. Please make data_status_header() public static when moving this to the current test layout. It uses no instance state, and PHPUnit 11 rejects non-static providers. I ran the same cases with the static provider on Core’s PHPUnit 9.6 runner.
AI review · gpt-6

This PR introduces a new test class Tests_Functions_StatusHeader to provide PHPUnit test coverage for the status_header() function in wp-includes/functions.php.
The tests cover:
•Standard HTTP status codes (200, 404, 301) and their default descriptions.
•Custom status descriptions provided as the second argument.
•Handling of unknown status codes (early return vs. using custom description).
•Verification that the server protocol (e.g., HTTP/1.1) is correctly respected in the generated header.
Since header() calls are difficult to test directly in a CLI environment, these tests rely on the status_header filter to intercept and verify the generated header string.
Trac ticket: https://core.trac.wordpress.org/ticket/65650
AI Disclosure:
•AI assistance: Yes
•Tool(s): Junie (JetBrains)
•Model(s): gemini-3-flash-preview
•Used for: Code analysis, test implementation, and workflow management.