Reuse user accounts in AJAX test suites.#12599
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
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.
Pull request overview
This PR updates the AJAX PHPUnit base test case to reduce repeated user creation by caching a user ID per role when switching roles via _setRole(), with the intent of speeding up AJAX test execution.
Changes:
- Add a
_user_idsproperty to store user IDs created for specific roles. - Update
_setRole()to reuse a previously created user ID for the requested role instead of always creating a new user.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Bot was correct, time advantage was chance (probably due to lack of people around).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
tests/phpunit/includes/testcase-ajax.php:22
- The docblock is now slightly misleading: it refers to
self::_setRole()(suggesting a static call) and it no longer accurately describes how the cache is populated (it’s filled inset_up_before_class()). It also lacks an@vartag, unlike other properties in this class.
/**
* User IDs created by self::_setRole().
*
* This stores the user IDs of various roles to allow for reuse.
*/
|
This is a nope. Creating the shared fixtures in the test suite slows things down rather than speeds thigns up. A lot of accounts are created but evidently fewer than this PR creates. |
Try speeding up the AJAX test suite by re-using roles between tests.
Looks to save about a minute on the full PHPUnit action (which is only about a second on each individual test suite).
Trac ticket: https://core.trac.wordpress.org/ticket/64894
Use of AI Tools
VS Code/Co-pilot type ahead.
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.