Skip to content

65650 functions status header - #12565

Open
pbearne wants to merge 8 commits into
WordPress:trunkfrom
pbearne:65650-functions-status_header
Open

pbearne wants to merge 8 commits into
WordPress:trunkfrom
pbearne:65650-functions-status_header

Conversation

@pbearne

@pbearne pbearne commented Jul 16, 2026

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

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:

Props pbearne.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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>
@pbearne
pbearne requested a balanced review from Copilot November 4, 2026 23:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the added PHPUnit coverage of WordPress’s status_header() function.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@pbearne
pbearne requested a review from lancewillett November 5, 2026 00:20

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants