Repository navigation
Tests: Reset the entity actions registry before each Tests_Entity_Actions test. - #16259
mayankmajeji wants to merge 2 commits into
Conversation
…tions` test. The class only reset the registry after each test, so when an earlier class had read it, the first test of the class saw the actions WordPress registers instead of the test defaults. Reset it in `set_up()` as well. See #66755.
|
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:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the change that resets the registry between tests.
No open issues 🎉
What changed in this PR
This PR fixes an order-dependent failure in Tests_Entity_Actions by ensuring each test starts with a fresh registry that uses the class’s test defaults rather than actions retained from earlier tests.
Changes:
- Reset the registry in
set_up()after installing the test-default registration callback. - Update the setup documentation to explain why the reset is needed.
| File | Description |
|---|---|
tests/phpunit/tests/entity-actions.php |
Reset the registry before each test and document the isolation requirement. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
I reproduced the preload test failing after the block-editor preload test on both single-site and multisite. Resetting the registry during setup made the same pair pass all six assertions in both modes. The existing teardown can only reset the registry after the class has started running. The code is good to go. Please apply Mukesh’s wording suggestion so the comment accurately describes when the reset runs.
AI review · gpt-6.2-astra
|
One separate finding for the isolation ticket. With seed 20261126 on single-site, this patch fixed the entity-action preload failure. The other failure also reproduces on trunk with just Calling |
lancewillett
left a comment
There was a problem hiding this comment.
Verified the wording change and resolved the thread. The block-editor preload test followed by the entity-actions preload test failed before the reset and passed all six assertions after it in both site modes.
AI review · gpt-6.2-astra
Trac ticket: https://core.trac.wordpress.org/ticket/66755
Tests_Entity_Actions::set_up()replacesregister_core_entity_actions()onwp_entity_actions_api_initwith the test defaults (the rename and trash actions of pages), but it only resets theWP_Entity_Actions_Registrysingleton intear_down(). When an earlier class has already read the registry, the first test of the class gets that registry, which holds the actions WordPress registers, andwp_entity_actions_api_initdoes not fire again.That happens after
Tests_Blocks_Editor::test_block_editor_rest_api_preload_discards_assets_enqueued_during_preload(), which runs the block editor preload and so reads the registry with the core actions. Iftest_the_preloaded_actions_path_serves_the_actions()is the firstTests_Entity_Actionstest to run after it, the preloaded response for pages holds the 11 core actions instead of the 2 defaults:What changes
Tests_Entity_Actions::set_up()also resets the registry, after hooking the test defaults, so every test starts from an empty registry as the class expects.Testing
Locally with PHP 8.4.28, MySQL 9.7.4 and PHPUnit 9.6.39, on trunk at r65798 (90582b1).
The config below runs
blocks/editor.phpandentity-actions.php, and the--filterkeeps the two tests above, in that order.vendor/bin/phpunit -c chain.xml --filter '/Tests_Blocks_Editor::test_block_editor_rest_api_preload_discards_assets_enqueued_during_preload|Tests_Entity_Actions::test_the_preloaded_actions_path_serves_the_actions/': 1 failure on trunk, OK (2 tests, 6 assertions) with this change.<const name="WP_TESTS_MULTISITE" value="1" />added).Tests_Entity_Actionsin default order, with--order-by=reverse, and with--order-by=randomand seeds 7, 1717 and 20261126: OK (66 tests) with this change.Tests_Entity_Actions,Tests_Blocks_Editor,WP_Test_REST_Entity_Actions_Controllerand theTests_Entity_Fieldsclasses together with--order-by=random --random-order-seed=3: OK (206 tests).--order-by=random --random-order-seed=20261126on single site (1 failure). With this change, the same full run has no failures (32402 tests).