Repository navigation
Tests: Cover prepare_item_for_response() in navigation fallback controller - #14385
rejaulalomkhan wants to merge 1 commit into
Conversation
…oller. Replace empty test_prepare_item() stub with assertions for response status, returned ID, and self link. Add test_prepare_item_limit_fields() to verify _links exclusion when fields are limited. See #40538, #66073.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
There was a problem hiding this comment.
🟢 Approval recommended
The test-only changes match the controller’s existing behavior, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Adds focused test coverage for the navigation fallback controller’s response preparation, replacing an empty test stub.
Changes:
- Verifies response type, status, navigation ID, and embeddable self link.
- Checks that
_fields=idpreserves the ID and omits links.
| File | Description |
|---|---|
| tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php | Adds response preparation and field-filtering assertions. |
Review effort: Balanced
Replace the empty `test_prepare_item()` stub with assertions for the navigation ID, response status, and embeddable `self` link returned by `WP_REST_Navigation_Fallback_Controller::prepare_item_for_response()`. Verify that requesting only `id` through `_fields` omits links. Developed in: #14385 Props rejaulalomkhan. See #40538, #66073. git-svn-id: https://develop.svn.wordpress.org/trunk@64452 602fd350-edb4-49c9-b593-d223f7449a82
|
PR #14385 landed in https://core.trac.wordpress.org/changeset/64452 |
Replace the empty `test_prepare_item()` stub with assertions for the navigation ID, response status, and embeddable `self` link returned by `WP_REST_Navigation_Fallback_Controller::prepare_item_for_response()`. Verify that requesting only `id` through `_fields` omits links. Developed in: WordPress/wordpress-develop#14385 Props rejaulalomkhan. See #40538, #66073. Built from https://develop.svn.wordpress.org/trunk@64452 git-svn-id: http://core.svn.wordpress.org/trunk@63602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/40538
See also: https://core.trac.wordpress.org/ticket/66073
Description
In
tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php,test_prepare_item()was an empty stub annotated with@doesNotPerformAssertions.This PR replaces the stub with test coverage for
WP_REST_Navigation_Fallback_Controller::prepare_item_for_response():test_prepare_item(): Verifies theWP_REST_Responseinstance, HTTP 200 status, returnediddata, and the presence and embeddability of theselflink.test_prepare_item_limit_fields(): Verifies that requesting specific_fieldslimits the response and properly omits_linkswhen not requested.Follow-up to [64273].
Testing Instructions
vendor/bin/phpcs tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.phpvendor/bin/phpunit --filter WP_REST_Navigation_Fallback_Controller_Testvendor/bin/phpunit -c tests/phpunit/multisite.xml --filter WP_REST_Navigation_Fallback_Controller_TestAll tests pass cleanly.
Use of AI Tools:
I used Antigravity (Gemini 2.5 Pro) to analyze
prepare_item_for_response()inWP_REST_Navigation_Fallback_Controller, verify_fieldshandling, run local PHPCS and PHPUnit test suites, and write test assertions following core REST controller test conventions.