Repository navigation
Tests: Add unit coverage for rest_get_route_for_post() - #15286
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 REST route generation, invalid posts, non-REST post types, and filter overrides. See #65819.
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for this test-only change adding direct coverage of rest_get_route_for_post().
No open issues 🎉
What changed in this PR
Adds direct PHPUnit coverage for rest_get_route_for_post() as part of the #65819 test cleanup effort. This is a test-only change with no production code modifications.
Changes:
- Verifies route generation for posts and empty results for invalid posts or post types not exposed through REST.
- Tests route overrides through the
rest_route_for_postfilter. - Adds explicit
@coversmetadata for the helper.
| File | Description |
|---|---|
tests/phpunit/tests/rest-api/restGetRouteForPost.php |
Adds a dedicated test class covering route generation, empty results, and filter overrides. |
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_get_route_for_post(), covering route generation for posts, invalid posts, non-REST post types, and filter overrides.Test-only; no production code changes.
Why
rest_get_route_for_post()had no direct@coverscoverage. Small helper coverage fits the #65819 test cleanup track.How
Add
tests/phpunit/tests/rest-api/restGetRouteForPost.phpwith@covers ::rest_get_route_for_post./wp/v2/posts/{id}for a postshow_in_restrest_route_for_postto replace the routeTesting Instructions
npm run test:php -- --filter Tests_REST_API_RestGetRouteForPostnpm run test:php -- --filter Tests_REST_API_RestGetRouteForPost -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_REST_API_RestGetRouteForPost --order-by=randomnpm run test:php -- --group restapiUse of AI Tools