Repository navigation
Tests: Add unit coverage for rest_get_route_for_post_type_items() - #15288
shail-mehta wants to merge 3 commits into
Conversation
Add unit tests for REST post type collection routes, invalid types, custom namespace/base, and filter overrides. See #65819.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the added PHPUnit coverage of REST post-type collection routes.
No open issues 🎉
What changed in this PR
Adds direct PHPUnit coverage for rest_get_route_for_post_type_items() as part of the #65819 test cleanup effort. No production code changes are included.
Changes:
- Tests standard collection routes and empty results for invalid or non-REST post types.
- Verifies custom REST namespaces, bases, and filter overrides.
- Adds an explicit
@coversannotation and cleanup for registered test post types.
| File | Description |
|---|---|
tests/phpunit/tests/rest-api/restGetRouteForPostTypeItems.php |
Adds a dedicated test class covering route generation and overrides. |
Review effort: Balanced
|
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:
|
lancewillett
left a comment
There was a problem hiding this comment.
Please remove the local tear_down() override. Parent set_up() already calls reset_post_types() before each core test, and this class has no earlier fixture consumer. Keep the new collection guard/filter checks.
AI review · gpt-6
Parent set_up() already resets post types before each test. See #65819.
|
Thanks for the Review! Addressed in 0564b0f |
Trac ticket: #65819
What
Adds a dedicated PHPUnit class for
rest_get_route_for_post_type_items(), covering collection routes, invalid post types, non-REST types, custom namespace/base, and filter overrides.Test-only; no production code changes.
Why
rest_get_route_for_post_type_items()had no direct@coverscoverage. Small helper coverage fits the #65819 test cleanup track.How
Add
tests/phpunit/tests/rest-api/restGetRouteForPostTypeItems.phpwith@covers ::rest_get_route_for_post_type_items./wp/v2/postsfor theposttypeshow_in_restrest_namespaceandrest_basewhen registeredrest_route_for_post_type_itemsto replace the routeTesting Instructions
npm run test:php -- --filter Tests_REST_API_RestGetRouteForPostTypeItemsnpm run test:php -- --filter Tests_REST_API_RestGetRouteForPostTypeItems -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_REST_API_RestGetRouteForPostTypeItems --order-by=randomnpm run test:php -- --group restapiUse of AI Tools