Tests: Optimize REST server setup in Tests_REST_API - #13694
SainathPoojary wants to merge 3 commits into
Conversation
|
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. |
| rest_get_server(); | ||
|
|
||
| $rest_server = $GLOBALS['wp_rest_server']; | ||
| $GLOBALS['wp_rest_server'] = null; |
There was a problem hiding this comment.
I don't think these are needed, since it's just nulling out the server anyway. The test passes without these lines, since it's just testing rest_preload_api_request().
| rest_get_server(); | |
| $rest_server = $GLOBALS['wp_rest_server']; | |
| $GLOBALS['wp_rest_server'] = null; |
There was a problem hiding this comment.
The $GLOBALS['wp_rest_server'] = $rest_server; is not needed anymore
| rest_get_server(); | ||
|
|
||
| $rest_server = $GLOBALS['wp_rest_server']; | ||
| $GLOBALS['wp_rest_server'] = null; |
There was a problem hiding this comment.
| rest_get_server(); | |
| $rest_server = $GLOBALS['wp_rest_server']; | |
| $GLOBALS['wp_rest_server'] = null; |
Reduces unnecessary REST server setup in
Tests_REST_API.Previously, every test created a
Spy_REST_Serverand initialized all REST routes, including helper tests that did not need them.This change initializes the server only where needed using
rest_get_server(). The test bootstrap continues to selectSpy_REST_Server. Setup and teardown clear the server to preserve test isolation.Performance
Measured locally across three runs:
Trac ticket: https://core.trac.wordpress.org/ticket/66074
Use of AI Tools
AI assistance: Yes
Tool(s): Github Copilot
Used for: Edge-case checks, and assistance with the PR description. Implementation and testing were made and reviewed by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.