Tests: Remove implicit dependencies on some leaky state - #13091
Conversation
`self::$theme_root` should be reverted in `WP_Font_Face_UnitTestCase` `self::$requires_switch_theme_fixtures` needs to be set before calling `parent::set_up_before_class()`.
…itemaps` `@runInSeparateProcess` reruns `tests/phpunit/includes/bootstrap.php`, which deletes all posts, which changes the conditions of the test. In particular, `test_disable_sitemap_should_return_404()` is supposed to test what happens if sitemaps are disabled, not what happens when there are no posts in the sitemap.
…self. These tests call `->render_control_template_scripts()`, which depends on a normally lazy-loaded file: `wp-includes/media-template.php`. Previous tests in these classes load that file as a side-effect of calling `$widget->enqueue_admin_scripts()`. When testing these tests individually, that file is never loaded. Load it explicitly.
Test methods that register new block types should unregister them as well. Otherwise, the state leaks into later tests.
|
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. |
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. |
There are a bunch of PHPUnit tests that implicitly depend on state leaked from other tests. This leaky state isn't observed in "normal" test runs, but can be easily seen by running:
Leaky state can cause several problems:
Trac ticket: https://core.trac.wordpress.org/ticket/65893
Use of AI Tools
AI assistance: Yes
Tool: Claude Code
Model: Opus 5
Used for: Analysis for failing tests, initial implementation; final implementation reviewed/edited 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.