diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index c87e5e7fd077c..82ed157cf3e0c 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -230,6 +230,9 @@ public function tear_down() { $this->_restore_hooks(); wp_set_current_user( 0 ); + // Synchronize the translation controller with the restored site locale. + WP_Translation_Controller::get_instance()->set_locale( determine_locale() ); + $this->reset_lazyload_queue(); WP_Style_Engine_CSS_Rules_Store::remove_all_stores(); diff --git a/tests/phpunit/tests/l10n/wpLocaleSwitcher.php b/tests/phpunit/tests/l10n/wpLocaleSwitcher.php index f24ca7695ca9b..2499ee751b599 100644 --- a/tests/phpunit/tests/l10n/wpLocaleSwitcher.php +++ b/tests/phpunit/tests/l10n/wpLocaleSwitcher.php @@ -26,6 +26,11 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase { */ protected $orig_instance; + /** + * @var WP_Locale + */ + protected $orig_wp_locale; + public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { self::$user_id = $factory->user->create( array( @@ -43,11 +48,12 @@ public function set_up() { unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); - global $wp_textdomain_registry, $wp_locale_switcher; + global $wp_textdomain_registry, $wp_locale_switcher, $wp_locale; $wp_textdomain_registry = new WP_Textdomain_Registry(); - $this->orig_instance = $wp_locale_switcher; + $this->orig_instance = $wp_locale_switcher; + $this->orig_wp_locale = $wp_locale; remove_all_filters( 'locale' ); remove_all_filters( 'determine_locale' ); @@ -59,7 +65,7 @@ public function set_up() { public function tear_down() { unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); - global $wp_textdomain_registry, $wp_locale_switcher; + global $wp_textdomain_registry, $wp_locale_switcher, $wp_locale; $wp_textdomain_registry = new WP_Textdomain_Registry(); @@ -71,6 +77,7 @@ public function tear_down() { remove_all_filters( 'determine_locale' ); $wp_locale_switcher = $this->orig_instance; + $wp_locale = $this->orig_wp_locale; unload_textdomain( 'internationalized-plugin' ); unload_textdomain( 'custom-internationalized-theme' );