Repository navigation
Tests: Add unit coverage for rest_get_route_for_taxonomy_items() - #15289
Draft
shail-mehta wants to merge 3 commits into
Draft
shail-mehta wants to merge 3 commits into
shail-mehta wants to merge 3 commits into
Conversation
Add unit tests for REST taxonomy collection routes, invalid taxonomies, custom namespace/base, and filter overrides. See #65819.
There was a problem hiding this comment.
🟡 Changes recommended
The tests leave the default REST base and namespace fallbacks untested and do not verify the filter’s route and taxonomy arguments.
2 open issues
What changed in this PR
Adds direct PHPUnit coverage for rest_get_route_for_taxonomy_items() as part of the REST API test cleanup tracked in #65819. No production code changes.
Changes:
- Covers category collection routes, invalid taxonomies, and taxonomies not exposed through REST.
- Tests custom namespaces and bases, plus filter-based route overrides.
- Adds taxonomy cleanup and a dedicated
@coversannotation.
| File | Description |
|---|---|
tests/phpunit/tests/rest-api/restGetRouteForTaxonomyItems.php |
Adds five focused tests for taxonomy collection route generation. |
Review effort: Balanced
Cover default namespace/base fallbacks and assert the filter receives the original route and taxonomy. See #65819.
Assert registration defaults, then exercise empty rest_base and empty rest_namespace fallbacks independently. See #65819.
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_taxonomy_items(), covering collection routes, invalid taxonomies, non-REST taxonomies, custom namespace/base, and filter overrides.Test-only; no production code changes.
Why
rest_get_route_for_taxonomy_items()had no direct@coverscoverage. Small helper coverage fits the #65819 test cleanup track.How
Add
tests/phpunit/tests/rest-api/restGetRouteForTaxonomyItems.phpwith@covers ::rest_get_route_for_taxonomy_items./wp/v2/categoriesfor thecategorytaxonomyshow_in_restrest_namespaceandrest_basewhen registeredrest_route_for_taxonomy_itemsto replace the routeTesting Instructions
npm run test:php -- --filter Tests_REST_API_RestGetRouteForTaxonomyItemsnpm run test:php -- --filter Tests_REST_API_RestGetRouteForTaxonomyItems -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_REST_API_RestGetRouteForTaxonomyItems --order-by=randomnpm run test:php -- --group restapiUse of AI Tools