Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 10 additions & 3 deletions tests/phpunit/tests/l10n/wpLocaleSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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' );
Expand All @@ -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();

Expand All @@ -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' );
Expand Down
Loading