mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Build/Test Tools: Add @covers tags to the l10n and i18n tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev. See #39265. git-svn-id: https://develop.svn.wordpress.org/trunk@53866 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -17,6 +17,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35961
|
||||
*
|
||||
* @covers ::_n_noop
|
||||
*/
|
||||
public function test_n_noop() {
|
||||
$text_domain = 'text-domain';
|
||||
@@ -30,6 +32,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35961
|
||||
*
|
||||
* @covers ::_nx_noop
|
||||
*/
|
||||
public function test_nx_noop() {
|
||||
$text_domain = 'text-domain';
|
||||
@@ -44,6 +48,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35073
|
||||
*
|
||||
* @covers ::before_last_bar
|
||||
*/
|
||||
public function test_before_last_bar() {
|
||||
$this->assertSame( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) );
|
||||
@@ -53,6 +59,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35950
|
||||
*
|
||||
* @covers ::get_available_languages
|
||||
*/
|
||||
public function test_get_available_languages() {
|
||||
$array = get_available_languages();
|
||||
@@ -67,6 +75,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35284
|
||||
*
|
||||
* @covers ::wp_get_installed_translations
|
||||
*/
|
||||
public function test_wp_get_installed_translations_for_core() {
|
||||
$installed_translations = wp_get_installed_translations( 'core' );
|
||||
@@ -89,6 +99,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35294
|
||||
*
|
||||
* @covers ::wp_dropdown_languages
|
||||
*/
|
||||
public function test_wp_dropdown_languages() {
|
||||
$args = array(
|
||||
@@ -111,6 +123,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 38632
|
||||
*
|
||||
* @covers ::wp_dropdown_languages
|
||||
*/
|
||||
public function test_wp_dropdown_languages_site_default() {
|
||||
$args = array(
|
||||
@@ -135,6 +149,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44494
|
||||
*
|
||||
* @covers ::wp_dropdown_languages
|
||||
*/
|
||||
public function test_wp_dropdown_languages_exclude_en_us() {
|
||||
$args = array(
|
||||
@@ -153,6 +169,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 38632
|
||||
*
|
||||
* @covers ::wp_dropdown_languages
|
||||
*/
|
||||
public function test_wp_dropdown_languages_en_US_selected() {
|
||||
$args = array(
|
||||
@@ -175,6 +193,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Add site default language to ja_JP in dropdown
|
||||
*
|
||||
* @covers ::wp_dropdown_languages
|
||||
*/
|
||||
public function test_wp_dropdown_languages_site_default_ja_JP() {
|
||||
$args = array(
|
||||
@@ -199,6 +219,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Select dropdown language from de_DE to ja_JP
|
||||
*
|
||||
* @covers ::wp_dropdown_languages
|
||||
*/
|
||||
public function test_wp_dropdown_languages_ja_JP_selected() {
|
||||
$args = array(
|
||||
@@ -246,6 +268,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35284
|
||||
*
|
||||
* @covers ::wp_get_pomo_file_data
|
||||
*/
|
||||
public function test_wp_get_pomo_file_data() {
|
||||
$file = DIR_TESTDATA . '/pomo/empty.po';
|
||||
@@ -272,6 +296,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::the_excerpt
|
||||
*/
|
||||
public function test_length_of_excerpt_should_be_counted_by_words() {
|
||||
global $post;
|
||||
@@ -296,6 +322,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::the_excerpt
|
||||
*/
|
||||
public function test_length_of_excerpt_should_be_counted_by_chars() {
|
||||
global $post;
|
||||
@@ -320,6 +348,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::the_excerpt
|
||||
*/
|
||||
public function test_length_of_excerpt_should_be_counted_by_chars_in_japanese() {
|
||||
global $post;
|
||||
@@ -344,6 +374,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::the_excerpt_rss
|
||||
*/
|
||||
public function test_length_of_excerpt_rss_should_be_counted_by_words() {
|
||||
global $post;
|
||||
@@ -368,6 +400,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::the_excerpt_rss
|
||||
*/
|
||||
public function test_length_of_excerpt_rss_should_be_counted_by_chars() {
|
||||
global $post;
|
||||
@@ -393,6 +427,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::wp_dashboard_recent_drafts
|
||||
*/
|
||||
public function test_length_of_draft_should_be_counted_by_words() {
|
||||
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
|
||||
@@ -417,6 +453,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::wp_dashboard_recent_drafts
|
||||
*/
|
||||
public function test_length_of_draft_should_be_counted_by_chars() {
|
||||
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
|
||||
@@ -441,6 +479,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::wp_dashboard_recent_drafts
|
||||
*/
|
||||
public function test_length_of_draft_should_be_counted_by_chars_in_japanese() {
|
||||
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
|
||||
@@ -465,6 +505,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::get_comment_excerpt
|
||||
*/
|
||||
public function test_length_of_comment_excerpt_should_be_counted_by_words() {
|
||||
switch_to_locale( 'en_US' );
|
||||
@@ -483,6 +525,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::get_comment_excerpt
|
||||
*/
|
||||
public function test_length_of_comment_excerpt_should_be_counted_by_chars() {
|
||||
switch_to_locale( 'ja_JP' );
|
||||
@@ -501,6 +545,8 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 44541
|
||||
*
|
||||
* @covers ::get_comment_excerpt
|
||||
*/
|
||||
public function test_length_of_comment_excerpt_should_be_counted_by_chars_in_Japanese() {
|
||||
switch_to_locale( 'ja_JP' );
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
/**
|
||||
* @group l10n
|
||||
* @group i18n
|
||||
*
|
||||
* @covers ::get_locale
|
||||
*/
|
||||
class Tests_L10n_GetLocale extends WP_UnitTestCase {
|
||||
public function test_should_respect_locale_global() {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
/**
|
||||
* @group l10n
|
||||
* @group i18n
|
||||
*
|
||||
* @covers ::get_user_locale
|
||||
*/
|
||||
class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
|
||||
protected $user_id;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
/**
|
||||
* @group l10n
|
||||
* @group i18n
|
||||
*
|
||||
* @covers ::load_script_textdomain
|
||||
*/
|
||||
class Tests_L10n_LoadScriptTextdomain extends WP_UnitTestCase {
|
||||
|
||||
|
||||
@@ -32,14 +32,23 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
return $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::is_textdomain_loaded
|
||||
*/
|
||||
public function test_is_textdomain_loaded() {
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unload_textdomain
|
||||
*/
|
||||
public function test_unload_textdomain() {
|
||||
$this->assertFalse( unload_textdomain( 'wp-tests-domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unload_textdomain
|
||||
*/
|
||||
public function test_load_textdomain() {
|
||||
$loaded = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
|
||||
|
||||
@@ -48,6 +57,9 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
$this->assertTrue( $loaded );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unload_textdomain
|
||||
*/
|
||||
public function test_is_textdomain_loaded_after_loading() {
|
||||
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
|
||||
|
||||
@@ -58,12 +70,18 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
$this->assertTrue( $loaded );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unload_textdomain
|
||||
*/
|
||||
public function test_unload_textdomain_after_loading() {
|
||||
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
|
||||
|
||||
$this->assertTrue( unload_textdomain( 'wp-tests-domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::is_textdomain_loaded
|
||||
*/
|
||||
public function test_is_textdomain_loaded_after_unloading() {
|
||||
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
|
||||
|
||||
@@ -74,6 +92,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 21319
|
||||
*
|
||||
* @covers ::load_textdomain
|
||||
*/
|
||||
public function test_load_textdomain_non_existent_file() {
|
||||
$this->assertFalse( load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ) );
|
||||
@@ -81,6 +101,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 21319
|
||||
*
|
||||
* @covers ::is_textdomain_loaded
|
||||
*/
|
||||
public function test_is_textdomain_loaded_non_existent_file() {
|
||||
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
|
||||
@@ -90,6 +112,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 21319
|
||||
*
|
||||
* @covers ::get_translations_for_domain
|
||||
*/
|
||||
public function test_get_translations_for_domain_non_existent_file() {
|
||||
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
|
||||
@@ -99,6 +123,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 21319
|
||||
*
|
||||
* @covers ::unload_textdomain
|
||||
*/
|
||||
public function test_unload_textdomain_non_existent_file() {
|
||||
load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
|
||||
@@ -108,6 +134,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 21319
|
||||
*
|
||||
* @covers ::is_textdomain_loaded
|
||||
*/
|
||||
public function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
@@ -115,6 +143,9 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::load_textdomain
|
||||
*/
|
||||
public function test_override_load_textdomain_noop() {
|
||||
add_filter( 'override_load_textdomain', '__return_true' );
|
||||
$load_textdomain = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
|
||||
@@ -124,6 +155,9 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::load_textdomain
|
||||
*/
|
||||
public function test_override_load_textdomain_non_existent_mofile() {
|
||||
add_filter( 'override_load_textdomain', array( $this, 'override_load_textdomain_filter' ), 10, 3 );
|
||||
$load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/non-existent-file.mo' );
|
||||
@@ -138,6 +172,9 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
$this->assertFalse( $is_textdomain_loaded_after );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::load_textdomain
|
||||
*/
|
||||
public function test_override_load_textdomain_custom_mofile() {
|
||||
add_filter( 'override_load_textdomain', array( $this, 'override_load_textdomain_filter' ), 10, 3 );
|
||||
$load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' );
|
||||
@@ -180,6 +217,9 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::load_muplugin_textdomain
|
||||
*/
|
||||
public function test_load_muplugin_textdomain_site_locale() {
|
||||
load_muplugin_textdomain( 'wp-tests-domain' );
|
||||
|
||||
@@ -188,6 +228,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 38485
|
||||
*
|
||||
* @covers ::load_muplugin_textdomain
|
||||
*/
|
||||
public function test_load_muplugin_textdomain_user_locale() {
|
||||
set_current_screen( 'dashboard' );
|
||||
@@ -198,6 +240,9 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
$this->assertSame( get_user_locale(), $this->locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::load_plugin_textdomain
|
||||
*/
|
||||
public function test_load_plugin_textdomain_site_locale() {
|
||||
load_plugin_textdomain( 'wp-tests-domain' );
|
||||
|
||||
@@ -206,6 +251,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 38485
|
||||
*
|
||||
* @covers ::load_plugin_textdomain
|
||||
*/
|
||||
public function test_load_plugin_textdomain_user_locale() {
|
||||
set_current_screen( 'dashboard' );
|
||||
@@ -216,6 +263,9 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
$this->assertSame( get_user_locale(), $this->locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::load_theme_textdomain
|
||||
*/
|
||||
public function test_load_theme_textdomain_site_locale() {
|
||||
load_theme_textdomain( 'wp-tests-domain' );
|
||||
|
||||
@@ -224,6 +274,8 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 38485
|
||||
*
|
||||
* @covers ::load_theme_textdomain
|
||||
*/
|
||||
public function test_load_theme_textdomain_user_locale() {
|
||||
set_current_screen( 'dashboard' );
|
||||
|
||||
@@ -62,6 +62,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 34114
|
||||
*
|
||||
* @covers ::is_textdomain_loaded
|
||||
*/
|
||||
public function test_plugin_translation_should_be_translated_without_calling_load_plugin_textdomain() {
|
||||
add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
|
||||
@@ -81,6 +83,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 34114
|
||||
*
|
||||
* @covers ::is_textdomain_loaded
|
||||
*/
|
||||
public function test_theme_translation_should_be_translated_without_calling_load_theme_textdomain() {
|
||||
add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
|
||||
@@ -102,6 +106,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 34114
|
||||
*
|
||||
* @covers ::get_translations_for_domain
|
||||
*/
|
||||
public function test_get_translations_for_domain_does_not_return_null_if_override_load_textdomain_is_used() {
|
||||
add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
|
||||
@@ -115,6 +121,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 37113
|
||||
*
|
||||
* @covers ::is_textdomain_loaded
|
||||
*/
|
||||
public function test_should_allow_unloading_of_text_domain() {
|
||||
add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
|
||||
@@ -154,6 +162,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 26511
|
||||
*
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_plugin_translation_after_switching_locale() {
|
||||
require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
|
||||
@@ -167,6 +177,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 37997
|
||||
*
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_plugin_translation_after_switching_locale_twice() {
|
||||
require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
|
||||
@@ -185,6 +197,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 26511
|
||||
*
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_theme_translation_after_switching_locale() {
|
||||
switch_theme( 'internationalized-theme' );
|
||||
@@ -202,6 +216,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 38485
|
||||
*
|
||||
* @covers ::wp_set_current_user
|
||||
*/
|
||||
public function test_plugin_translation_with_user_locale() {
|
||||
require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
|
||||
@@ -216,6 +232,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 38485
|
||||
*
|
||||
* @covers ::wp_set_current_user
|
||||
*/
|
||||
public function test_theme_translation_with_user_locale() {
|
||||
switch_theme( 'internationalized-theme' );
|
||||
@@ -233,6 +251,8 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 37997
|
||||
*
|
||||
* @covers ::_load_textdomain_just_in_time
|
||||
*/
|
||||
public function test_get_locale_is_called_only_once_per_textdomain() {
|
||||
$textdomain = 'foo-bar-baz';
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
/**
|
||||
* @group l10n
|
||||
* @group i18n
|
||||
*
|
||||
* @covers ::translate_settings_using_i18n_schema
|
||||
*/
|
||||
class Tests_L10n_TranslateSettingsUsingI18nSchema extends WP_UnitTestCase {
|
||||
/**
|
||||
|
||||
@@ -35,16 +35,25 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_non_existent_locale_returns_false() {
|
||||
$this->assertFalse( switch_to_locale( 'foo_BAR' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_non_existent_locale_does_not_change_locale() {
|
||||
switch_to_locale( 'foo_BAR' );
|
||||
|
||||
$this->assertSame( 'en_US', get_locale() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_locale_returns_true() {
|
||||
$expected = switch_to_locale( 'en_GB' );
|
||||
|
||||
@@ -54,6 +63,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertTrue( $expected );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_locale_changes_the_locale() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
|
||||
@@ -65,6 +77,11 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'en_GB', $locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
* @covers ::translate
|
||||
* @covers ::__
|
||||
*/
|
||||
public function test_switch_to_locale_loads_translation() {
|
||||
switch_to_locale( 'es_ES' );
|
||||
|
||||
@@ -76,6 +93,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'Parámetro no válido. ', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_locale_changes_wp_locale_global() {
|
||||
global $wp_locale;
|
||||
|
||||
@@ -94,6 +114,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSameSetsWithIndex( $expected, $wp_locale_de_de->number_format );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_locale_en_US() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
$locale_en_gb = get_locale();
|
||||
@@ -107,6 +130,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'en_US', $locale_en_us );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_locale_multiple_times() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
switch_to_locale( 'es_ES' );
|
||||
@@ -119,6 +145,11 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'es_ES', $locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
* @covers ::__
|
||||
* @covers ::translate
|
||||
*/
|
||||
public function test_switch_to_locale_multiple_times_loads_translation() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
switch_to_locale( 'de_DE' );
|
||||
@@ -134,10 +165,16 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'Parámetro no válido. ', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_previous_locale
|
||||
*/
|
||||
public function test_restore_previous_locale_without_switching() {
|
||||
$this->assertFalse( restore_previous_locale() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_previous_locale
|
||||
*/
|
||||
public function test_restore_previous_locale_changes_the_locale_back() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
|
||||
@@ -147,6 +184,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'en_US', get_locale() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_previous_locale
|
||||
*/
|
||||
public function test_restore_previous_locale_after_switching_multiple_times() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
switch_to_locale( 'es_ES' );
|
||||
@@ -160,6 +200,11 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'en_GB', $locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_previous_locale
|
||||
* @covers ::__
|
||||
* @covers ::translate
|
||||
*/
|
||||
public function test_restore_previous_locale_restores_translation() {
|
||||
switch_to_locale( 'es_ES' );
|
||||
restore_previous_locale();
|
||||
@@ -169,6 +214,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'Invalid parameter.', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_previous_locale
|
||||
*/
|
||||
public function test_restore_previous_locale_action_passes_previous_locale() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
switch_to_locale( 'es_ES' );
|
||||
@@ -185,6 +233,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'es_ES', $previous_locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_previous_locale
|
||||
*/
|
||||
public function test_restore_previous_locale_restores_wp_locale_global() {
|
||||
global $wp_locale;
|
||||
|
||||
@@ -199,10 +250,16 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSameSetsWithIndex( $expected, $wp_locale->number_format );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_current_locale
|
||||
*/
|
||||
public function test_restore_current_locale_without_switching() {
|
||||
$this->assertFalse( restore_current_locale() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::restore_previous_locale
|
||||
*/
|
||||
public function test_restore_current_locale_after_switching_multiple_times() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
switch_to_locale( 'nl_NL' );
|
||||
@@ -218,10 +275,16 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->previous_locale = $previous_locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::is_locale_switched
|
||||
*/
|
||||
public function test_is_locale_switched_if_not_switched() {
|
||||
$this->assertFalse( is_locale_switched() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::is_locale_switched
|
||||
*/
|
||||
public function test_is_locale_switched_original_locale() {
|
||||
$original_locale = get_locale();
|
||||
|
||||
@@ -235,6 +298,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertTrue( $is_locale_switched );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::is_locale_switched
|
||||
*/
|
||||
public function test_is_locale_switched() {
|
||||
switch_to_locale( 'en_GB' );
|
||||
switch_to_locale( 'nl_NL' );
|
||||
@@ -246,6 +312,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertTrue( $is_locale_switched );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_site_locale_if_user_locale_is_set() {
|
||||
global $l10n, $wp_locale_switcher;
|
||||
|
||||
@@ -292,6 +361,9 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'de_DE', $language_header_after_restore );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
*/
|
||||
public function test_switch_to_different_site_locale_if_user_locale_is_set() {
|
||||
global $l10n, $wp_locale_switcher;
|
||||
|
||||
@@ -343,6 +415,10 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
$this->assertSame( 'de_DE', $language_header_after_restore );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::switch_to_locale
|
||||
* @covers ::load_default_textdomain
|
||||
*/
|
||||
public function test_multiple_switches_to_site_locale_and_user_locale() {
|
||||
global $wp_locale_switcher;
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->locale = new WP_Locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_weekday
|
||||
*/
|
||||
public function test_get_weekday() {
|
||||
$this->assertSame( __( 'Sunday' ), $this->locale->get_weekday( 0 ) );
|
||||
$this->assertSame( __( 'Monday' ), $this->locale->get_weekday( 1 ) );
|
||||
@@ -25,6 +28,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->assertSame( __( 'Saturday' ), $this->locale->get_weekday( 6 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_weekday
|
||||
*/
|
||||
public function test_get_weekday_undefined_index() {
|
||||
if ( PHP_VERSION_ID >= 80000 ) {
|
||||
$this->expectWarning();
|
||||
@@ -35,6 +41,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->locale->get_weekday( 7 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_weekday_initial
|
||||
*/
|
||||
public function test_get_weekday_initial() {
|
||||
$this->assertSame( __( 'S' ), $this->locale->get_weekday_initial( __( 'Sunday' ) ) );
|
||||
$this->assertSame( __( 'M' ), $this->locale->get_weekday_initial( __( 'Monday' ) ) );
|
||||
@@ -45,6 +54,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->assertSame( __( 'S' ), $this->locale->get_weekday_initial( __( 'Saturday' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_weekday_abbrev
|
||||
*/
|
||||
public function test_get_weekday_abbrev() {
|
||||
$this->assertSame( __( 'Sun' ), $this->locale->get_weekday_abbrev( __( 'Sunday' ) ) );
|
||||
$this->assertSame( __( 'Mon' ), $this->locale->get_weekday_abbrev( __( 'Monday' ) ) );
|
||||
@@ -55,6 +67,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->assertSame( __( 'Sat' ), $this->locale->get_weekday_abbrev( __( 'Saturday' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_month
|
||||
*/
|
||||
public function test_get_month() {
|
||||
$this->assertSame( __( 'January' ), $this->locale->get_month( 1 ) );
|
||||
$this->assertSame( __( 'February' ), $this->locale->get_month( 2 ) );
|
||||
@@ -70,6 +85,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->assertSame( __( 'December' ), $this->locale->get_month( 12 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_month
|
||||
*/
|
||||
public function test_get_month_leading_zero() {
|
||||
$this->assertSame( __( 'January' ), $this->locale->get_month( '01' ) );
|
||||
$this->assertSame( __( 'February' ), $this->locale->get_month( '02' ) );
|
||||
@@ -82,6 +100,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->assertSame( __( 'September' ), $this->locale->get_month( '09' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_month_abbrev
|
||||
*/
|
||||
public function test_get_month_abbrev() {
|
||||
$this->assertSame( __( 'Jan' ), $this->locale->get_month_abbrev( __( 'January' ) ) );
|
||||
$this->assertSame( __( 'Feb' ), $this->locale->get_month_abbrev( __( 'February' ) ) );
|
||||
@@ -97,6 +118,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->assertSame( __( 'Dec' ), $this->locale->get_month_abbrev( __( 'December' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::get_meridiem
|
||||
*/
|
||||
public function test_get_meridiem() {
|
||||
$this->assertSame( __( 'am' ), $this->locale->get_meridiem( 'am' ) );
|
||||
$this->assertSame( __( 'AM' ), $this->locale->get_meridiem( 'AM' ) );
|
||||
@@ -104,6 +128,9 @@ class Tests_Locale extends WP_UnitTestCase {
|
||||
$this->assertSame( __( 'PM' ), $this->locale->get_meridiem( 'PM' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers WP_Locale::is_rtl
|
||||
*/
|
||||
public function test_is_rtl() {
|
||||
$this->assertFalse( $this->locale->is_rtl() );
|
||||
$this->locale->text_direction = 'foo';
|
||||
|
||||
Reference in New Issue
Block a user