@@ -67,31 +67,21 @@ function register_widgets() {
67
67
* @group basic
68
68
*/
69
69
public function load_textdomain () {
70
+ global $ wp_version ;
70
71
$ 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
+ }
85
78
}
86
79
87
80
/**
88
81
* @test
89
82
* @group basic
90
83
*/
91
84
public function load_textdomain_change () {
92
- $ loaded = $ this ->custom_post_type_widgets ->load_textdomain ();
93
- $ this ->assertTrue ( $ loaded );
94
-
95
85
unload_textdomain ( 'custom-post-type-widgets ' );
96
86
$ this ->assertFalse ( isset ( $ l10n [ 'custom-post-type-widgets ' ] ) );
97
87
@@ -101,27 +91,25 @@ public function load_textdomain_change() {
101
91
$ loaded = $ this ->custom_post_type_widgets ->load_textdomain ();
102
92
$ this ->assertTrue ( $ loaded );
103
93
104
- $ this ->assertSame ( 'ja_JP ' , get_locale () );
94
+ $ this ->assertSame ( 'ja ' , get_locale () );
105
95
106
96
remove_filter ( 'load_textdomain_mofile ' , [ $ this , '_change_textdomain_mofile ' ] );
107
97
remove_filter ( 'locale ' , [ $ this , '_change_locale ' ] );
108
98
109
99
unload_textdomain ( 'custom-post-type-widgets ' );
110
100
$ this ->assertFalse ( isset ( $ l10n [ 'custom-post-type-widgets ' ] ) );
111
-
112
- switch_to_locale ( 'en_US ' );
113
101
}
114
102
115
103
/**
116
104
* hook for load_textdomain
117
105
*/
118
106
function _change_locale ( $ locale ) {
119
- return 'ja_JP ' ;
107
+ return 'ja ' ;
120
108
}
121
109
122
110
function _change_textdomain_mofile ( $ mofile , $ domain ) {
123
111
if ( $ domain === 'custom-post-type-widgets ' ) {
124
- $ locale = determine_locale ();
112
+ $ locale = get_locale ();
125
113
$ mofile = plugin_dir_path ( __CUSTOM_POST_TYPE_WIDGETS__ ) . 'languages/custom-post-type-widgets- ' . $ locale . '.mo ' ;
126
114
127
115
$ this ->assertSame ( $ locale , get_locale () );
0 commit comments