From d08321a2bf65dfa4bcb83c5d207c932f974d1be0 Mon Sep 17 00:00:00 2001 From: Mayank Majeji <2611064+mayankmajeji@users.noreply.github.com> Date: Wed, 25 Nov 2026 23:05:38 +0530 Subject: [PATCH] Tests: Reset the `$wp_customize` global after each test. Several tests leave a `WP_Customize_Manager` in the global, so the first test of a later class runs as if in a Customizer preview. Reset it in `tear_down()` next to the other globals. See #66755. --- tests/phpunit/includes/abstract-testcase.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index 7dd0fddde9bb6..ee93c99c58fca 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -396,6 +396,9 @@ public function tear_down() { $GLOBALS[ $global ] = null; } + // Reset the Customizer global so that `is_customize_preview()` is false when the next test runs. + $GLOBALS['wp_customize'] = null; + // Reset comment globals. $comment_globals = array( 'comment_alt', 'comment_depth', 'comment_thread_alt', 'in_comment_loop' ); foreach ( $comment_globals as $global ) {