<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[50456] trunk/tests/phpunit/tests/l10n: Tests: Rename classes in `phpunit/tests/l10n/` per the naming conventions.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50456">50456</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50456","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-02-28 17:22:27 +0000 (Sun, 28 Feb 2021)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Tests: Rename classes in `phpunit/tests/l10n/` per the naming conventions.

https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to <a href="https://core.trac.wordpress.org/changeset/47780">[47780]</a>, <a href="https://core.trac.wordpress.org/changeset/48911">[48911]</a>, <a href="https://core.trac.wordpress.org/changeset/49327">[49327]</a>, <a href="https://core.trac.wordpress.org/changeset/50291">[50291]</a>, <a href="https://core.trac.wordpress.org/changeset/50292">[50292]</a>, <a href="https://core.trac.wordpress.org/changeset/50342">[50342]</a>, <a href="https://core.trac.wordpress.org/changeset/50452">[50452]</a>, <a href="https://core.trac.wordpress.org/changeset/50453">[50453]</a>.

See <a href="https://core.trac.wordpress.org/ticket/52625">#52625</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsl10ngetUserLocalephp">trunk/tests/phpunit/tests/l10n/getUserLocale.php</a></li>
<li><a href="#trunktestsphpunittestsl10nloadScriptTextdomainphp">trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php</a></li>
<li><a href="#trunktestsphpunittestsl10nloadTextdomainphp">trunk/tests/phpunit/tests/l10n/loadTextdomain.php</a></li>
<li><a href="#trunktestsphpunittestsl10nloadTextdomainJustInTimephp">trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsl10nwpLocaleSwitcherphp">trunk/tests/phpunit/tests/l10n/wpLocaleSwitcher.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsl10nlocaleSwitcherphp">trunk/tests/phpunit/tests/l10n/localeSwitcher.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsl10ngetUserLocalephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/l10n/getUserLocale.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/getUserLocale.php  2021-02-28 17:12:03 UTC (rev 50455)
+++ trunk/tests/phpunit/tests/l10n/getUserLocale.php    2021-02-28 17:22:27 UTC (rev 50456)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,7 +4,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @group l10n
</span><span class="cx" style="display: block; padding: 0 10px">  * @group i18n
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class Tests_Get_User_Locale extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">         protected $user_id;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function setUp() {
</span></span></pre></div>
<a id="trunktestsphpunittestsl10nloadScriptTextdomainphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php   2021-02-28 17:12:03 UTC (rev 50455)
+++ trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php     2021-02-28 17:22:27 UTC (rev 50456)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,7 +4,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @group l10n
</span><span class="cx" style="display: block; padding: 0 10px">  * @group i18n
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class Tests_L10n_loadScriptTextdomain extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_L10n_LoadScriptTextdomain extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 45528
</span></span></pre></div>
<a id="trunktestsphpunittestsl10nloadTextdomainphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/l10n/loadTextdomain.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/loadTextdomain.php 2021-02-28 17:12:03 UTC (rev 50455)
+++ trunk/tests/phpunit/tests/l10n/loadTextdomain.php   2021-02-28 17:22:27 UTC (rev 50456)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,7 +4,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @group l10n
</span><span class="cx" style="display: block; padding: 0 10px">  * @group i18n
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">         protected $locale;
</span><span class="cx" style="display: block; padding: 0 10px">        protected static $user_id;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunktestsphpunittestsl10nloadTextdomainJustInTimephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php       2021-02-28 17:12:03 UTC (rev 50455)
+++ trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php 2021-02-28 17:22:27 UTC (rev 50456)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,7 +4,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @group l10n
</span><span class="cx" style="display: block; padding: 0 10px">  * @group i18n
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">         protected $orig_theme_dir;
</span><span class="cx" style="display: block; padding: 0 10px">        protected $theme_root;
</span><span class="cx" style="display: block; padding: 0 10px">        protected static $user_id;
</span></span></pre></div>
<a id="trunktestsphpunittestsl10nlocaleSwitcherphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/l10n/localeSwitcher.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/localeSwitcher.php 2021-02-28 17:12:03 UTC (rev 50455)
+++ trunk/tests/phpunit/tests/l10n/localeSwitcher.php   2021-02-28 17:22:27 UTC (rev 50456)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,394 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-/**
- * @group l10n
- * @group i18n
- * @ticket 26511
- */
-class Tests_Locale_Switcher extends WP_UnitTestCase {
-       /**
-        * @var string
-        */
-       protected $locale = '';
-
-       /**
-        * @var string
-        */
-       protected $previous_locale = '';
-
-       public function setUp() {
-               parent::setUp();
-
-               $this->locale          = '';
-               $this->previous_locale = '';
-
-               unset( $GLOBALS['l10n'] );
-               unset( $GLOBALS['l10n_unloaded'] );
-               _get_path_to_translation( null, true );
-       }
-
-       public function tearDown() {
-               unset( $GLOBALS['l10n'] );
-               unset( $GLOBALS['l10n_unloaded'] );
-               _get_path_to_translation( null, true );
-
-               parent::tearDown();
-       }
-
-       public function test_switch_to_non_existent_locale_returns_false() {
-               $this->assertFalse( switch_to_locale( 'foo_BAR' ) );
-       }
-
-       public function test_switch_to_non_existent_locale_does_not_change_locale() {
-               switch_to_locale( 'foo_BAR' );
-
-               $this->assertSame( 'en_US', get_locale() );
-       }
-
-       public function test_switch_to_locale_returns_true() {
-               $expected = switch_to_locale( 'en_GB' );
-
-               // Cleanup.
-               restore_previous_locale();
-
-               $this->assertTrue( $expected );
-       }
-
-       public function test_switch_to_locale_changes_the_locale() {
-               switch_to_locale( 'en_GB' );
-
-               $locale = get_locale();
-
-               // Cleanup.
-               restore_previous_locale();
-
-               $this->assertSame( 'en_GB', $locale );
-       }
-
-       public function test_switch_to_locale_loads_translation() {
-               switch_to_locale( 'es_ES' );
-
-               $actual = __( 'Invalid parameter.' );
-
-               // Cleanup.
-               restore_previous_locale();
-
-               $this->assertSame( 'Parámetro no válido. ', $actual );
-       }
-
-       public function test_switch_to_locale_changes_wp_locale_global() {
-               global $wp_locale;
-
-               $expected = array(
-                       'thousands_sep' => '.',
-                       'decimal_point' => ',',
-               );
-
-               switch_to_locale( 'de_DE' );
-
-               $wp_locale_de_de = clone $wp_locale;
-
-               // Cleanup.
-               restore_previous_locale();
-
-               $this->assertSameSetsWithIndex( $expected, $wp_locale_de_de->number_format );
-       }
-
-       public function test_switch_to_locale_en_US() {
-               switch_to_locale( 'en_GB' );
-               $locale_en_gb = get_locale();
-               switch_to_locale( 'en_US' );
-               $locale_en_us = get_locale();
-
-               // Cleanup.
-               restore_current_locale();
-
-               $this->assertSame( 'en_GB', $locale_en_gb );
-               $this->assertSame( 'en_US', $locale_en_us );
-       }
-
-       public function test_switch_to_locale_multiple_times() {
-               switch_to_locale( 'en_GB' );
-               switch_to_locale( 'es_ES' );
-               $locale = get_locale();
-
-               // Cleanup.
-               restore_previous_locale();
-               restore_previous_locale();
-
-               $this->assertSame( 'es_ES', $locale );
-       }
-
-       public function test_switch_to_locale_multiple_times_loads_translation() {
-               switch_to_locale( 'en_GB' );
-               switch_to_locale( 'de_DE' );
-               switch_to_locale( 'es_ES' );
-
-               $actual = __( 'Invalid parameter.' );
-
-               // Cleanup.
-               restore_previous_locale();
-               restore_previous_locale();
-               restore_previous_locale();
-
-               $this->assertSame( 'Parámetro no válido. ', $actual );
-       }
-
-       public function test_restore_previous_locale_without_switching() {
-               $this->assertFalse( restore_previous_locale() );
-       }
-
-       public function test_restore_previous_locale_changes_the_locale_back() {
-               switch_to_locale( 'en_GB' );
-
-               // Cleanup.
-               restore_previous_locale();
-
-               $this->assertSame( 'en_US', get_locale() );
-       }
-
-       public function test_restore_previous_locale_after_switching_multiple_times() {
-               switch_to_locale( 'en_GB' );
-               switch_to_locale( 'es_ES' );
-               restore_previous_locale();
-
-               $locale = get_locale();
-
-               // Cleanup.
-               restore_previous_locale();
-
-               $this->assertSame( 'en_GB', $locale );
-       }
-
-       public function test_restore_previous_locale_restores_translation() {
-               switch_to_locale( 'es_ES' );
-               restore_previous_locale();
-
-               $actual = __( 'Invalid parameter.' );
-
-               $this->assertSame( 'Invalid parameter.', $actual );
-       }
-
-       public function test_restore_previous_locale_action_passes_previous_locale() {
-               switch_to_locale( 'en_GB' );
-               switch_to_locale( 'es_ES' );
-
-               add_action( 'restore_previous_locale', array( $this, 'store_locale' ), 10, 2 );
-
-               restore_previous_locale();
-
-               $previous_locale = $this->previous_locale;
-
-               // Cleanup.
-               restore_previous_locale();
-
-               $this->assertSame( 'es_ES', $previous_locale );
-       }
-
-       public function test_restore_previous_locale_restores_wp_locale_global() {
-               global $wp_locale;
-
-               $expected = array(
-                       'thousands_sep' => ',',
-                       'decimal_point' => '.',
-               );
-
-               switch_to_locale( 'de_DE' );
-               restore_previous_locale();
-
-               $this->assertSameSetsWithIndex( $expected, $wp_locale->number_format );
-       }
-
-       public function test_restore_current_locale_without_switching() {
-               $this->assertFalse( restore_current_locale() );
-       }
-
-       public function test_restore_current_locale_after_switching_multiple_times() {
-               switch_to_locale( 'en_GB' );
-               switch_to_locale( 'nl_NL' );
-               switch_to_locale( 'es_ES' );
-
-               restore_current_locale();
-
-               $this->assertSame( 'en_US', get_locale() );
-       }
-
-       public function store_locale( $locale, $previous_locale ) {
-               $this->locale          = $locale;
-               $this->previous_locale = $previous_locale;
-       }
-
-       public function test_is_locale_switched_if_not_switched() {
-               $this->assertFalse( is_locale_switched() );
-       }
-
-       public function test_is_locale_switched_original_locale() {
-               $original_locale = get_locale();
-
-               switch_to_locale( 'en_GB' );
-               switch_to_locale( $original_locale );
-
-               $is_locale_switched = is_locale_switched();
-
-               restore_current_locale();
-
-               $this->assertTrue( $is_locale_switched );
-       }
-
-       public function test_is_locale_switched() {
-               switch_to_locale( 'en_GB' );
-               switch_to_locale( 'nl_NL' );
-
-               $is_locale_switched = is_locale_switched();
-
-               restore_current_locale();
-
-               $this->assertTrue( $is_locale_switched );
-       }
-
-       public function test_switch_to_site_locale_if_user_locale_is_set() {
-               global $l10n, $wp_locale_switcher;
-
-               $site_locale = get_locale();
-
-               $user_id = $this->factory()->user->create(
-                       array(
-                               'role'   => 'administrator',
-                               'locale' => 'de_DE',
-                       )
-               );
-
-               wp_set_current_user( $user_id );
-               set_current_screen( 'dashboard' );
-
-               $locale_switcher = clone $wp_locale_switcher;
-
-               $wp_locale_switcher = new WP_Locale_Switcher();
-               $wp_locale_switcher->init();
-
-               $user_locale = get_user_locale();
-
-               $this->assertSame( 'de_DE', $user_locale );
-
-               load_default_textdomain( $user_locale );
-               $language_header_before_switch = $l10n['default']->headers['Language']; // de_DE
-
-               $locale_switched_user_locale  = switch_to_locale( $user_locale ); // False.
-               $locale_switched_site_locale  = switch_to_locale( $site_locale ); // True.
-               $site_locale_after_switch     = get_locale();
-               $language_header_after_switch = isset( $l10n['default'] ); // en_US
-
-               restore_current_locale();
-
-               $language_header_after_restore = $l10n['default']->headers['Language']; // de_DE
-
-               $wp_locale_switcher = $locale_switcher;
-
-               set_current_screen( 'front' );
-
-               $this->assertFalse( $locale_switched_user_locale );
-               $this->assertTrue( $locale_switched_site_locale );
-               $this->assertSame( $site_locale, $site_locale_after_switch );
-               $this->assertSame( 'de_DE', $language_header_before_switch );
-               $this->assertFalse( $language_header_after_switch );
-               $this->assertSame( 'de_DE', $language_header_after_restore );
-       }
-
-       public function test_switch_to_different_site_locale_if_user_locale_is_set() {
-               global $l10n, $wp_locale_switcher;
-
-               // Change site locale to es_ES.
-               add_filter( 'locale', array( $this, 'filter_locale' ) );
-
-               $site_locale = get_locale();
-
-               $user_id = $this->factory()->user->create(
-                       array(
-                               'role'   => 'administrator',
-                               'locale' => 'de_DE',
-                       )
-               );
-
-               wp_set_current_user( $user_id );
-               set_current_screen( 'dashboard' );
-
-               $locale_switcher = clone $wp_locale_switcher;
-
-               $wp_locale_switcher = new WP_Locale_Switcher();
-               $wp_locale_switcher->init();
-
-               $user_locale = get_user_locale();
-
-               $this->assertSame( 'de_DE', $user_locale );
-
-               load_default_textdomain( $user_locale );
-               $language_header_before_switch = $l10n['default']->headers['Language']; // de_DE
-
-               $locale_switched_user_locale  = switch_to_locale( $user_locale ); // False.
-               $locale_switched_site_locale  = switch_to_locale( $site_locale ); // True.
-               $site_locale_after_switch     = get_locale();
-               $language_header_after_switch = $l10n['default']->headers['Language']; // es_ES
-
-               restore_current_locale();
-
-               $language_header_after_restore = $l10n['default']->headers['Language']; // de_DE
-
-               $wp_locale_switcher = $locale_switcher;
-
-               set_current_screen( 'front' );
-
-               remove_filter( 'locale', array( $this, 'filter_locale' ) );
-
-               $this->assertFalse( $locale_switched_user_locale );
-               $this->assertTrue( $locale_switched_site_locale );
-               $this->assertSame( $site_locale, $site_locale_after_switch );
-               $this->assertSame( 'de_DE', $language_header_before_switch );
-               $this->assertSame( 'es_ES', $language_header_after_switch );
-               $this->assertSame( 'de_DE', $language_header_after_restore );
-       }
-
-       public function test_multiple_switches_to_site_locale_and_user_locale() {
-               global $wp_locale_switcher;
-
-               $site_locale = get_locale();
-
-               $user_id = $this->factory()->user->create(
-                       array(
-                               'role'   => 'administrator',
-                               'locale' => 'en_GB',
-                       )
-               );
-
-               wp_set_current_user( $user_id );
-               set_current_screen( 'dashboard' );
-
-               $locale_switcher = clone $wp_locale_switcher;
-
-               $wp_locale_switcher = new WP_Locale_Switcher();
-               $wp_locale_switcher->init();
-
-               $user_locale = get_user_locale();
-
-               load_default_textdomain( $user_locale );
-
-               require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
-
-               switch_to_locale( 'de_DE' );
-               switch_to_locale( $site_locale );
-
-               $expected = i18n_plugin_test();
-
-               restore_current_locale();
-
-               $wp_locale_switcher = $locale_switcher;
-
-               set_current_screen( 'front' );
-
-               $this->assertSame( 'en_US', get_locale() );
-               $this->assertSame( 'This is a dummy plugin', $expected );
-       }
-
-       public function filter_locale() {
-               return 'es_ES';
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsl10nwpLocaleSwitcherphpfromrev50455trunktestsphpunittestsl10nlocaleSwitcherphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/l10n/wpLocaleSwitcher.php (from rev 50455, trunk/tests/phpunit/tests/l10n/localeSwitcher.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/wpLocaleSwitcher.php                               (rev 0)
+++ trunk/tests/phpunit/tests/l10n/wpLocaleSwitcher.php 2021-02-28 17:22:27 UTC (rev 50456)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,394 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * @group l10n
+ * @group i18n
+ * @ticket 26511
+ */
+class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
+       /**
+        * @var string
+        */
+       protected $locale = '';
+
+       /**
+        * @var string
+        */
+       protected $previous_locale = '';
+
+       public function setUp() {
+               parent::setUp();
+
+               $this->locale          = '';
+               $this->previous_locale = '';
+
+               unset( $GLOBALS['l10n'] );
+               unset( $GLOBALS['l10n_unloaded'] );
+               _get_path_to_translation( null, true );
+       }
+
+       public function tearDown() {
+               unset( $GLOBALS['l10n'] );
+               unset( $GLOBALS['l10n_unloaded'] );
+               _get_path_to_translation( null, true );
+
+               parent::tearDown();
+       }
+
+       public function test_switch_to_non_existent_locale_returns_false() {
+               $this->assertFalse( switch_to_locale( 'foo_BAR' ) );
+       }
+
+       public function test_switch_to_non_existent_locale_does_not_change_locale() {
+               switch_to_locale( 'foo_BAR' );
+
+               $this->assertSame( 'en_US', get_locale() );
+       }
+
+       public function test_switch_to_locale_returns_true() {
+               $expected = switch_to_locale( 'en_GB' );
+
+               // Cleanup.
+               restore_previous_locale();
+
+               $this->assertTrue( $expected );
+       }
+
+       public function test_switch_to_locale_changes_the_locale() {
+               switch_to_locale( 'en_GB' );
+
+               $locale = get_locale();
+
+               // Cleanup.
+               restore_previous_locale();
+
+               $this->assertSame( 'en_GB', $locale );
+       }
+
+       public function test_switch_to_locale_loads_translation() {
+               switch_to_locale( 'es_ES' );
+
+               $actual = __( 'Invalid parameter.' );
+
+               // Cleanup.
+               restore_previous_locale();
+
+               $this->assertSame( 'Parámetro no válido. ', $actual );
+       }
+
+       public function test_switch_to_locale_changes_wp_locale_global() {
+               global $wp_locale;
+
+               $expected = array(
+                       'thousands_sep' => '.',
+                       'decimal_point' => ',',
+               );
+
+               switch_to_locale( 'de_DE' );
+
+               $wp_locale_de_de = clone $wp_locale;
+
+               // Cleanup.
+               restore_previous_locale();
+
+               $this->assertSameSetsWithIndex( $expected, $wp_locale_de_de->number_format );
+       }
+
+       public function test_switch_to_locale_en_US() {
+               switch_to_locale( 'en_GB' );
+               $locale_en_gb = get_locale();
+               switch_to_locale( 'en_US' );
+               $locale_en_us = get_locale();
+
+               // Cleanup.
+               restore_current_locale();
+
+               $this->assertSame( 'en_GB', $locale_en_gb );
+               $this->assertSame( 'en_US', $locale_en_us );
+       }
+
+       public function test_switch_to_locale_multiple_times() {
+               switch_to_locale( 'en_GB' );
+               switch_to_locale( 'es_ES' );
+               $locale = get_locale();
+
+               // Cleanup.
+               restore_previous_locale();
+               restore_previous_locale();
+
+               $this->assertSame( 'es_ES', $locale );
+       }
+
+       public function test_switch_to_locale_multiple_times_loads_translation() {
+               switch_to_locale( 'en_GB' );
+               switch_to_locale( 'de_DE' );
+               switch_to_locale( 'es_ES' );
+
+               $actual = __( 'Invalid parameter.' );
+
+               // Cleanup.
+               restore_previous_locale();
+               restore_previous_locale();
+               restore_previous_locale();
+
+               $this->assertSame( 'Parámetro no válido. ', $actual );
+       }
+
+       public function test_restore_previous_locale_without_switching() {
+               $this->assertFalse( restore_previous_locale() );
+       }
+
+       public function test_restore_previous_locale_changes_the_locale_back() {
+               switch_to_locale( 'en_GB' );
+
+               // Cleanup.
+               restore_previous_locale();
+
+               $this->assertSame( 'en_US', get_locale() );
+       }
+
+       public function test_restore_previous_locale_after_switching_multiple_times() {
+               switch_to_locale( 'en_GB' );
+               switch_to_locale( 'es_ES' );
+               restore_previous_locale();
+
+               $locale = get_locale();
+
+               // Cleanup.
+               restore_previous_locale();
+
+               $this->assertSame( 'en_GB', $locale );
+       }
+
+       public function test_restore_previous_locale_restores_translation() {
+               switch_to_locale( 'es_ES' );
+               restore_previous_locale();
+
+               $actual = __( 'Invalid parameter.' );
+
+               $this->assertSame( 'Invalid parameter.', $actual );
+       }
+
+       public function test_restore_previous_locale_action_passes_previous_locale() {
+               switch_to_locale( 'en_GB' );
+               switch_to_locale( 'es_ES' );
+
+               add_action( 'restore_previous_locale', array( $this, 'store_locale' ), 10, 2 );
+
+               restore_previous_locale();
+
+               $previous_locale = $this->previous_locale;
+
+               // Cleanup.
+               restore_previous_locale();
+
+               $this->assertSame( 'es_ES', $previous_locale );
+       }
+
+       public function test_restore_previous_locale_restores_wp_locale_global() {
+               global $wp_locale;
+
+               $expected = array(
+                       'thousands_sep' => ',',
+                       'decimal_point' => '.',
+               );
+
+               switch_to_locale( 'de_DE' );
+               restore_previous_locale();
+
+               $this->assertSameSetsWithIndex( $expected, $wp_locale->number_format );
+       }
+
+       public function test_restore_current_locale_without_switching() {
+               $this->assertFalse( restore_current_locale() );
+       }
+
+       public function test_restore_current_locale_after_switching_multiple_times() {
+               switch_to_locale( 'en_GB' );
+               switch_to_locale( 'nl_NL' );
+               switch_to_locale( 'es_ES' );
+
+               restore_current_locale();
+
+               $this->assertSame( 'en_US', get_locale() );
+       }
+
+       public function store_locale( $locale, $previous_locale ) {
+               $this->locale          = $locale;
+               $this->previous_locale = $previous_locale;
+       }
+
+       public function test_is_locale_switched_if_not_switched() {
+               $this->assertFalse( is_locale_switched() );
+       }
+
+       public function test_is_locale_switched_original_locale() {
+               $original_locale = get_locale();
+
+               switch_to_locale( 'en_GB' );
+               switch_to_locale( $original_locale );
+
+               $is_locale_switched = is_locale_switched();
+
+               restore_current_locale();
+
+               $this->assertTrue( $is_locale_switched );
+       }
+
+       public function test_is_locale_switched() {
+               switch_to_locale( 'en_GB' );
+               switch_to_locale( 'nl_NL' );
+
+               $is_locale_switched = is_locale_switched();
+
+               restore_current_locale();
+
+               $this->assertTrue( $is_locale_switched );
+       }
+
+       public function test_switch_to_site_locale_if_user_locale_is_set() {
+               global $l10n, $wp_locale_switcher;
+
+               $site_locale = get_locale();
+
+               $user_id = $this->factory()->user->create(
+                       array(
+                               'role'   => 'administrator',
+                               'locale' => 'de_DE',
+                       )
+               );
+
+               wp_set_current_user( $user_id );
+               set_current_screen( 'dashboard' );
+
+               $locale_switcher = clone $wp_locale_switcher;
+
+               $wp_locale_switcher = new WP_Locale_Switcher();
+               $wp_locale_switcher->init();
+
+               $user_locale = get_user_locale();
+
+               $this->assertSame( 'de_DE', $user_locale );
+
+               load_default_textdomain( $user_locale );
+               $language_header_before_switch = $l10n['default']->headers['Language']; // de_DE
+
+               $locale_switched_user_locale  = switch_to_locale( $user_locale ); // False.
+               $locale_switched_site_locale  = switch_to_locale( $site_locale ); // True.
+               $site_locale_after_switch     = get_locale();
+               $language_header_after_switch = isset( $l10n['default'] ); // en_US
+
+               restore_current_locale();
+
+               $language_header_after_restore = $l10n['default']->headers['Language']; // de_DE
+
+               $wp_locale_switcher = $locale_switcher;
+
+               set_current_screen( 'front' );
+
+               $this->assertFalse( $locale_switched_user_locale );
+               $this->assertTrue( $locale_switched_site_locale );
+               $this->assertSame( $site_locale, $site_locale_after_switch );
+               $this->assertSame( 'de_DE', $language_header_before_switch );
+               $this->assertFalse( $language_header_after_switch );
+               $this->assertSame( 'de_DE', $language_header_after_restore );
+       }
+
+       public function test_switch_to_different_site_locale_if_user_locale_is_set() {
+               global $l10n, $wp_locale_switcher;
+
+               // Change site locale to es_ES.
+               add_filter( 'locale', array( $this, 'filter_locale' ) );
+
+               $site_locale = get_locale();
+
+               $user_id = $this->factory()->user->create(
+                       array(
+                               'role'   => 'administrator',
+                               'locale' => 'de_DE',
+                       )
+               );
+
+               wp_set_current_user( $user_id );
+               set_current_screen( 'dashboard' );
+
+               $locale_switcher = clone $wp_locale_switcher;
+
+               $wp_locale_switcher = new WP_Locale_Switcher();
+               $wp_locale_switcher->init();
+
+               $user_locale = get_user_locale();
+
+               $this->assertSame( 'de_DE', $user_locale );
+
+               load_default_textdomain( $user_locale );
+               $language_header_before_switch = $l10n['default']->headers['Language']; // de_DE
+
+               $locale_switched_user_locale  = switch_to_locale( $user_locale ); // False.
+               $locale_switched_site_locale  = switch_to_locale( $site_locale ); // True.
+               $site_locale_after_switch     = get_locale();
+               $language_header_after_switch = $l10n['default']->headers['Language']; // es_ES
+
+               restore_current_locale();
+
+               $language_header_after_restore = $l10n['default']->headers['Language']; // de_DE
+
+               $wp_locale_switcher = $locale_switcher;
+
+               set_current_screen( 'front' );
+
+               remove_filter( 'locale', array( $this, 'filter_locale' ) );
+
+               $this->assertFalse( $locale_switched_user_locale );
+               $this->assertTrue( $locale_switched_site_locale );
+               $this->assertSame( $site_locale, $site_locale_after_switch );
+               $this->assertSame( 'de_DE', $language_header_before_switch );
+               $this->assertSame( 'es_ES', $language_header_after_switch );
+               $this->assertSame( 'de_DE', $language_header_after_restore );
+       }
+
+       public function test_multiple_switches_to_site_locale_and_user_locale() {
+               global $wp_locale_switcher;
+
+               $site_locale = get_locale();
+
+               $user_id = $this->factory()->user->create(
+                       array(
+                               'role'   => 'administrator',
+                               'locale' => 'en_GB',
+                       )
+               );
+
+               wp_set_current_user( $user_id );
+               set_current_screen( 'dashboard' );
+
+               $locale_switcher = clone $wp_locale_switcher;
+
+               $wp_locale_switcher = new WP_Locale_Switcher();
+               $wp_locale_switcher->init();
+
+               $user_locale = get_user_locale();
+
+               load_default_textdomain( $user_locale );
+
+               require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
+
+               switch_to_locale( 'de_DE' );
+               switch_to_locale( $site_locale );
+
+               $expected = i18n_plugin_test();
+
+               restore_current_locale();
+
+               $wp_locale_switcher = $locale_switcher;
+
+               set_current_screen( 'front' );
+
+               $this->assertSame( 'en_US', get_locale() );
+               $this->assertSame( 'This is a dummy plugin', $expected );
+       }
+
+       public function filter_locale() {
+               return 'es_ES';
+       }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>