Repository navigation
Fix: clean up registered theme directories and theme cache in teardown - #896
Open
CookieDarb wants to merge 1 commit into
Open
CookieDarb wants to merge 1 commit into
CookieDarb wants to merge 1 commit into
Conversation
CookieDarb
marked this pull request as ready for review
October 22, 2026 11:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #895
Fixes a test isolation failure where
CbtThemeLocaleandCbtThemeReadmetest suites leak custom theme directory registrations into the global$wp_theme_directoriesarray and leave stale theme caches, causing 1 error and 5 failures in subsequent test classes (Test_Create_Block_Theme_ApiandTest_Create_Block_Theme_Fonts).Why?
CBT_Theme_Locale_UnitTestCaseandCBT_Theme_Readme_UnitTestCaseregisterDIR_TESTDATA . '/themes/'viaregister_theme_directory()duringset_up(). Intear_down(), they switch back to the original theme, but never remove the registered directory from$wp_theme_directoriesand never callwp_clean_themes_cache().This leaves registered theme directories leaked in the global
$wp_theme_directoriesarray and theme caches stale across the test suite. Subsequent tests that dynamically create themes on disk (such asTest_Create_Block_Theme_ApiandTest_Create_Block_Theme_Fonts) fail to resolve them properly, leading to test failures during full suite runs.How?
tests/CbtThemeLocale/base.php:$wp_theme_directoriesinset_up().$wp_theme_directoriesto its original state and calledwp_clean_themes_cache()intear_down().tests/CbtThemeReadme/base.php:$wp_theme_directoriesinset_up().$wp_theme_directoriesto its original state and calledwp_clean_themes_cache()intear_down().Testing Instructions
CBT_Theme_Locale_EscapeAttributeimmediately followed byTest_Create_Block_Theme_Api:npm run test:unit:php:base -- --filter "CBT_Theme_Locale_EscapeAttribute|Test_Create_Block_Theme_Api"Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Diagnosing test pollution root cause in WordPress Core theme lookup and implementing test teardown cleanup. Final decisions and edits were made by me.