@@ -795,9 +795,12 @@ public function test_update_network_option_should_conditionally_apply_site_and_o
795
795
public function test_update_network_option_should_add_option_with_filtered_default_value () {
796
796
global $ wpdb ;
797
797
798
- $ option = 'foo ' ;
799
- $ default_site_value = 'default-site-value ' ;
800
- $ default_option_value = 'default-option-value ' ;
798
+ if ( ! is_multisite () ) {
799
+ $ this ->markTestSkipped ();
800
+ }
801
+
802
+ $ option = 'foo ' ;
803
+ $ default_site_value = 'default-site-value ' ;
801
804
802
805
add_filter (
803
806
"default_site_option_ {$ option }" ,
@@ -806,40 +809,15 @@ static function () use ( $default_site_value ) {
806
809
}
807
810
);
808
811
809
- add_filter (
810
- "default_option_ {$ option }" ,
811
- static function () use ( $ default_option_value ) {
812
- return $ default_option_value ;
813
- }
814
- );
815
-
816
- /*
817
- * For a non existing option with the unfiltered default of false, passing false here wouldn't work.
818
- * Because the default is different than false here though, passing false is expected to result in
819
- * a database update.
820
- */
821
- $ this ->assertTrue ( update_network_option ( null , $ option , false ), 'update_network_option() should have returned true. ' );
822
-
823
- if ( is_multisite () ) {
824
- $ actual = $ wpdb ->get_row (
825
- $ wpdb ->prepare (
826
- "SELECT meta_value FROM $ wpdb ->sitemeta WHERE meta_key = %s LIMIT 1 " ,
827
- $ option
828
- )
829
- );
830
- } else {
831
- $ actual = $ wpdb ->get_row (
832
- $ wpdb ->prepare (
833
- "SELECT option_value FROM $ wpdb ->options WHERE option_name = %s LIMIT 1 " ,
834
- $ option
835
- )
836
- );
837
- }
812
+ $ this ->assertFalse ( update_network_option ( null , $ option , false ), 'update_network_option() should have returned false. ' );
838
813
839
- $ value_field = is_multisite () ? 'meta_value ' : 'option_value ' ;
814
+ $ actual = $ wpdb ->get_row (
815
+ $ wpdb ->prepare (
816
+ "SELECT meta_value FROM $ wpdb ->sitemeta WHERE meta_key = %s LIMIT 1 " ,
817
+ $ option
818
+ )
819
+ );
840
820
841
- $ this ->assertIsObject ( $ actual , 'The option was not added to the database. ' );
842
- $ this ->assertObjectHasProperty ( $ value_field , $ actual , "The ' $ value_field' property was not included. " );
843
- $ this ->assertSame ( '' , $ actual ->$ value_field , 'The new value was not stored in the database. ' );
821
+ $ this ->assertNull ( $ actual , 'The option was added to the database. ' );
844
822
}
845
823
}
0 commit comments