You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix test suite isolation by cleaning up registered theme directories and cache in teardown #895
Running the full PHPUnit test suite (npm run test:unit:php) produces 1 error and 5 failures across Test_Create_Block_Theme_Api and Test_Create_Block_Theme_Fonts, even though both test classes pass completely when run in isolation.
This happens because CBT_Theme_Locale_UnitTestCase (tests/CbtThemeLocale/base.php) and CBT_Theme_Readme_UnitTestCase (tests/CbtThemeReadme/base.php) register a custom test theme directory via register_theme_directory() in set_up(), but do not restore the global $wp_theme_directories array or call wp_clean_themes_cache() in tear_down().
Steps to Reproduce
Run CBT_Theme_Locale_EscapeAttribute immediately followed by Test_Create_Block_Theme_Api:
npm run test:unit:php:base -- --filter "CBT_Theme_Locale_EscapeAttribute|Test_Create_Block_Theme_Api"
Observe 2 failures in Test_Create_Block_Theme_Api.
Run Test_Create_Block_Theme_Api alone:
npm run test:unit:php:base -- --filter Test_Create_Block_Theme_Api
Observe that all tests pass.
Expected Behaviour
Tests should run in clean isolation. Base test cases that register custom theme directories should restore $wp_theme_directories and call wp_clean_themes_cache() in tear_down() so subsequent test suites are not polluted.
Actual Behaviour
Custom theme directories remain in the global $wp_theme_directories array and theme caches remain stale. Subsequent tests that dynamically create themes on disk fail to resolve them, leading to 1 error and 5 failures during full suite runs.
Activity