Tests: Avoid repeated user creation in WP_Test_REST_Post_Meta_Fields - #13589
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. |
|
I noticed a few of the CI test jobs are failing, so I spent some time investigating. I ran the tests locally, but they are passing for me without any issues. I also checked trunk and a few other open PRs, and it looks like these similar failures are happening there as well. Since this is happening other places as well, it seems like these might be random test failures rather than something caused by these changes. |
Optimizes fixture setup in
WP_Test_REST_Post_Meta_Fieldsby avoiding repeated editor user creation across individual tests.Previously,
grant_write_permission()called$factory->user->create()each time it was invoked (65+ calls across test methods and data provider iterations). This introduced unnecessary database insertions and teardown overhead for tests that only needed an authenticated editor user.This change creates a shared editor user once in
wpSetUpBeforeClass(), sets that user ingrant_write_permission(), and cleans it up viaself::delete_user()inwpTearDownAfterClass(). All 151 tests and 581 assertions remain unchanged and pass.Performance
Measured locally across three consecutive runs comparing
trunkto this branch: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 done 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.