Repository navigation
Tests: Add unit coverage for rest_parse_request_arg() - #15292
Draft
shail-mehta wants to merge 1 commit into
Draft
shail-mehta wants to merge 1 commit into
shail-mehta wants to merge 1 commit into
Conversation
Add unit tests for validate-then-sanitize parsing of REST request args, including invalid values. See #65819.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the added REST request argument parsing tests.
No open issues 🎉
What changed in this PR
Adds dedicated PHPUnit coverage for rest_parse_request_arg() as part of the REST API test cleanup tracked in #65819. No production code changes are included.
Changes:
- Adds a test class with an explicit
@coversannotation. - Checks integer and boolean sanitization for valid inputs.
- Checks that invalid integer input returns a
WP_Errorwith coderest_invalid_type.
| File | Description |
|---|---|
tests/phpunit/tests/rest-api/restParseRequestArg.php |
Adds direct tests for valid-value sanitization and invalid-value error handling. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac ticket: #65819
What
Adds a dedicated PHPUnit class for
rest_parse_request_arg(), covering validate-then-sanitize success paths and invalid-valueWP_Errorreturns.Test-only; no production code changes.
Why
rest_parse_request_arg()had no direct@coverscoverage. Small helper coverage fits the #65819 test cleanup track.How
Add
tests/phpunit/tests/rest-api/restParseRequestArg.phpwith@covers ::rest_parse_request_arg.rest_invalid_typeerror for invalid valuesTesting Instructions
npm run test:php -- --filter Tests_REST_API_RestParseRequestArgnpm run test:php -- --filter Tests_REST_API_RestParseRequestArg -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_REST_API_RestParseRequestArg --order-by=randomnpm run test:php -- --group restapiUse of AI Tools