@@ -67,31 +67,21 @@ function register_widgets() {
6767 * @group basic
6868 */
6969 public function load_textdomain () {
70+ global $ wp_version ;
7071 $ loaded = $ this ->custom_post_type_widgets ->load_textdomain ();
71- $ this ->assertTrue ( $ loaded );
72- }
73-
74- /**
75- * @test
76- * @group basic
77- */
78- public function load_textdomain_switch_to_locale () {
79- $ this ->assertTrue ( switch_to_locale ( 'ja_JP ' ) );
80-
81- $ loaded = $ this ->custom_post_type_widgets ->load_textdomain ();
82- $ this ->assertTrue ( $ loaded );
83-
84- switch_to_locale ( 'en_US ' );
72+ if ( version_compare ( (string ) $ wp_version , '6.7 ' , '>= ' ) ) {
73+ $ this ->assertTrue ( $ loaded );
74+ }
75+ else {
76+ $ this ->assertFalse ( $ loaded );
77+ }
8578 }
8679
8780 /**
8881 * @test
8982 * @group basic
9083 */
9184 public function load_textdomain_change () {
92- $ loaded = $ this ->custom_post_type_widgets ->load_textdomain ();
93- $ this ->assertTrue ( $ loaded );
94-
9585 unload_textdomain ( 'custom-post-type-widgets ' );
9686 $ this ->assertFalse ( isset ( $ l10n [ 'custom-post-type-widgets ' ] ) );
9787
@@ -101,27 +91,25 @@ public function load_textdomain_change() {
10191 $ loaded = $ this ->custom_post_type_widgets ->load_textdomain ();
10292 $ this ->assertTrue ( $ loaded );
10393
104- $ this ->assertSame ( 'ja_JP ' , get_locale () );
94+ $ this ->assertSame ( 'ja ' , get_locale () );
10595
10696 remove_filter ( 'load_textdomain_mofile ' , [ $ this , '_change_textdomain_mofile ' ] );
10797 remove_filter ( 'locale ' , [ $ this , '_change_locale ' ] );
10898
10999 unload_textdomain ( 'custom-post-type-widgets ' );
110100 $ this ->assertFalse ( isset ( $ l10n [ 'custom-post-type-widgets ' ] ) );
111-
112- switch_to_locale ( 'en_US ' );
113101 }
114102
115103 /**
116104 * hook for load_textdomain
117105 */
118106 function _change_locale ( $ locale ) {
119- return 'ja_JP ' ;
107+ return 'ja ' ;
120108 }
121109
122110 function _change_textdomain_mofile ( $ mofile , $ domain ) {
123111 if ( $ domain === 'custom-post-type-widgets ' ) {
124- $ locale = determine_locale ();
112+ $ locale = get_locale ();
125113 $ mofile = plugin_dir_path ( __CUSTOM_POST_TYPE_WIDGETS__ ) . 'languages/custom-post-type-widgets- ' . $ locale . '.mo ' ;
126114
127115 $ this ->assertSame ( $ locale , get_locale () );
0 commit comments