@@ -47,11 +47,16 @@ public function test_is_option_ignored() {
47
47
}
48
48
49
49
public function test_callback_updated_option () {
50
+ // If multisite use site_option methods and test "update_site_option" callback
51
+ // instead of the update_option callback.
52
+ $ add_method = is_multisite () ? 'add_site_option ' : 'add_option ' ;
53
+ $ update_method = is_multisite () ? 'update_site_option ' : 'update_option ' ;
54
+
50
55
// Create options in database for later use.
51
- add_option ( 'users_can_register ' , false );
52
- add_option ( 'permalink_structure ' , '' );
53
- add_option ( 'category_base ' , '' );
54
- add_option ( 'tag_base ' , '' );
56
+ call_user_func ( $ add_method , 'users_can_register ' , 0 );
57
+ call_user_func ( $ add_method , 'permalink_structure ' , '' );
58
+ call_user_func ( $ add_method , 'category_base ' , '' );
59
+ call_user_func ( $ add_method , 'tag_base ' , '' );
55
60
56
61
$ this ->mock ->expects ( $ this ->exactly ( 4 ) )
57
62
->method ( 'log ' )
@@ -123,22 +128,26 @@ public function test_callback_updated_option() {
123
128
do_action ( 'customize_save ' , new \WP_Customize_Manager ( array () ) );
124
129
125
130
// Update options to trigger callback.
126
- update_option ( 'users_can_register ' , true );
131
+ call_user_func ( $ update_method , 'users_can_register ' , 1 );
127
132
128
133
// Use this to prevent repeated log calls.
129
134
global $ wp_actions ;
130
135
unset( $ wp_actions ['customize_save ' ] );
131
136
132
- update_option ( 'permalink_structure ' , '/%year%/%postname%/ ' );
133
- update_option ( 'category_base ' , 'cat/ ' );
134
- update_option ( 'tag_base ' , 'tag/ ' );
135
-
136
-
137
- // Check callback test action.
138
- $ this ->assertGreaterThan ( 0 , did_action ( 'wp_stream_test_callback_updated_option ' ) );
139
- $ this ->assertGreaterThan ( 0 , did_action ( 'wp_stream_test_callback_update_option_tag_base ' ) );
140
- $ this ->assertGreaterThan ( 0 , did_action ( 'wp_stream_test_callback_update_option_category_base ' ) );
141
- $ this ->assertGreaterThan ( 0 , did_action ( 'wp_stream_test_callback_update_option_permalink_structure ' ) );
142
- $ this ->assertGreaterThan ( 0 , did_action ( 'wp_stream_test_callback_update_option ' ) );
137
+ call_user_func ( $ update_method , 'permalink_structure ' , '/%year%/%postname%/ ' );
138
+ call_user_func ( $ update_method , 'category_base ' , 'cat/ ' );
139
+ call_user_func ( $ update_method , 'tag_base ' , 'tag/ ' );
140
+
141
+ // If multisite only check update_site_option test callback.
142
+ if ( is_multisite () ) {
143
+ $ this ->assertGreaterThan ( 0 , did_action ( $ this ->action_prefix . 'callback_update_site_option ' ) );
144
+ } else {
145
+ // Check callback test action.
146
+ $ this ->assertGreaterThan ( 0 , did_action ( $ this ->action_prefix . 'callback_update_option_tag_base ' ) );
147
+ $ this ->assertGreaterThan ( 0 , did_action ( $ this ->action_prefix . 'callback_update_option_category_base ' ) );
148
+ $ this ->assertGreaterThan ( 0 , did_action ( $ this ->action_prefix . 'callback_update_option_permalink_structure ' ) );
149
+ $ this ->assertGreaterThan ( 0 , did_action ( $ this ->action_prefix . 'callback_updated_option ' ) );
150
+ $ this ->assertGreaterThan ( 0 , did_action ( $ this ->action_prefix . 'callback_update_option ' ) );
151
+ }
143
152
}
144
153
}
0 commit comments