Changeset 48937 for trunk/tests/phpunit/tests/customize/setting.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/setting.php
r47198 r48937 34 34 function test_constructor_without_args() { 35 35 $setting = new WP_Customize_Setting( $this->manager, 'foo' ); 36 $this->assert Equals( $this->manager, $setting->manager );37 $this->assert Equals( 'foo', $setting->id );38 $this->assert Equals( 'theme_mod', $setting->type );39 $this->assert Equals( 'edit_theme_options', $setting->capability );40 $this->assert Equals( '', $setting->theme_supports );41 $this->assert Equals( '', $setting->default );42 $this->assert Equals( 'refresh', $setting->transport );43 $this->assert Equals( '', $setting->sanitize_callback );44 $this->assert Equals( '', $setting->sanitize_js_callback );36 $this->assertSame( $this->manager, $setting->manager ); 37 $this->assertSame( 'foo', $setting->id ); 38 $this->assertSame( 'theme_mod', $setting->type ); 39 $this->assertSame( 'edit_theme_options', $setting->capability ); 40 $this->assertSame( '', $setting->theme_supports ); 41 $this->assertSame( '', $setting->default ); 42 $this->assertSame( 'refresh', $setting->transport ); 43 $this->assertSame( '', $setting->sanitize_callback ); 44 $this->assertSame( '', $setting->sanitize_js_callback ); 45 45 $this->assertFalse( has_filter( "customize_validate_{$setting->id}" ) ); 46 46 $this->assertFalse( has_filter( "customize_sanitize_{$setting->id}" ) ); 47 47 $this->assertFalse( has_filter( "customize_sanitize_js_{$setting->id}" ) ); 48 $this->assert Equals( false,$setting->dirty );48 $this->assertFalse( $setting->dirty ); 49 49 } 50 50 … … 101 101 ); 102 102 $setting = new WP_Customize_Setting( $this->manager, 'bar', $args ); 103 $this->assert Equals( 'bar', $setting->id );103 $this->assertSame( 'bar', $setting->id ); 104 104 foreach ( $args as $key => $value ) { 105 $this->assert Equals( $value, $setting->$key );105 $this->assertSame( $value, $setting->$key ); 106 106 } 107 $this->assert Equals( 10, has_filter( "customize_validate_{$setting->id}", $args['validate_callback'] ) );108 $this->assert Equals( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) );109 $this->assert Equals( 10, has_filter( "customize_sanitize_js_{$setting->id}", $args['sanitize_js_callback'] ) );107 $this->assertSame( 10, has_filter( "customize_validate_{$setting->id}", $args['validate_callback'] ) ); 108 $this->assertSame( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) ); 109 $this->assertSame( 10, has_filter( "customize_sanitize_js_{$setting->id}", $args['sanitize_js_callback'] ) ); 110 110 } 111 111 … … 147 147 $default = "default_value_{$name}"; 148 148 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 149 $this->assert Equals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );150 $this->assert Equals( $default, $setting->value() );149 $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) ); 150 $this->assertSame( $default, $setting->value() ); 151 151 $this->assertTrue( $setting->preview(), 'Preview should not no-op since setting has no existing value.' ); 152 $this->assert Equals( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) );153 $this->assert Equals( $default, $setting->value() );152 $this->assertSame( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) ); 153 $this->assertSame( $default, $setting->value() ); 154 154 155 155 // Non-multidimensional: See what effect the preview has on an extant setting (default value should not be seen). … … 159 159 call_user_func( $type_options['setter'], $name, $initial_value ); 160 160 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 161 $this->assert Equals( $initial_value, call_user_func( $type_options['getter'], $name ) );162 $this->assert Equals( $initial_value, $setting->value() );161 $this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name ) ); 162 $this->assertSame( $initial_value, $setting->value() ); 163 163 $this->assertFalse( $setting->preview(), 'Preview should no-op since setting value was extant and no post value was present.' ); 164 $this->assert Equals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).165 $this->assert Equals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).166 $this->assert Equals( $initial_value, call_user_func( $type_options['getter'], $name ) );167 $this->assert Equals( $initial_value, $setting->value() );164 $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods). 165 $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods). 166 $this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name ) ); 167 $this->assertSame( $initial_value, $setting->value() ); 168 168 169 169 // Non-multidimensional: Try updating a value that had a no-op preview. … … 171 171 call_user_func( $type_options['setter'], $name, $overridden_value ); 172 172 $message = 'Initial value should be overridden because initial preview() was no-op due to setting having existing value and/or post value was absent.'; 173 $this->assert Equals( $overridden_value, call_user_func( $type_options['getter'], $name ), $message );174 $this->assert Equals( $overridden_value, $setting->value(), $message );173 $this->assertSame( $overridden_value, call_user_func( $type_options['getter'], $name ), $message ); 174 $this->assertSame( $overridden_value, $setting->value(), $message ); 175 175 $this->assertNotEquals( $initial_value, $setting->value(), $message ); 176 176 177 177 // Non-multidimensional: Ensure that setting a post value *after* preview() is called results in the post value being seen (deferred preview). 178 178 $post_value = "post_value_for_{$setting->id}_set_after_preview_called"; 179 $this->assert Equals( 0, did_action( "customize_post_value_set_{$setting->id}" ) );179 $this->assertSame( 0, did_action( "customize_post_value_set_{$setting->id}" ) ); 180 180 $this->manager->set_post_value( $setting->id, $post_value ); 181 $this->assert Equals( 1, did_action( "customize_post_value_set_{$setting->id}" ) );181 $this->assertSame( 1, did_action( "customize_post_value_set_{$setting->id}" ) ); 182 182 $this->assertNotEquals( $overridden_value, $setting->value() ); 183 $this->assert Equals( $post_value, call_user_func( $type_options['getter'], $name ) );184 $this->assert Equals( $post_value, $setting->value() );183 $this->assertSame( $post_value, call_user_func( $type_options['getter'], $name ) ); 184 $this->assertSame( $post_value, $setting->value() ); 185 185 186 186 // Non-multidimensional: Test unset setting being overridden by a post value. … … 188 188 $default = "default_value_{$name}"; 189 189 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 190 $this->assert Equals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );191 $this->assert Equals( $default, $setting->value() );190 $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) ); 191 $this->assertSame( $default, $setting->value() ); 192 192 $this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // Activate post_data. 193 $this->assert Equals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );194 $this->assert Equals( $this->post_data_overrides[ $name ], $setting->value() );193 $this->assertSame( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) ); 194 $this->assertSame( $this->post_data_overrides[ $name ], $setting->value() ); 195 195 196 196 // Non-multidimensional: Test set setting being overridden by a post value. … … 200 200 call_user_func( $type_options['setter'], $name, $initial_value ); 201 201 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 202 $this->assert Equals( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) );203 $this->assert Equals( $initial_value, $setting->value() );202 $this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) ); 203 $this->assertSame( $initial_value, $setting->value() ); 204 204 $this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // Activate post_data. 205 $this->assert Equals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).206 $this->assert Equals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).207 $this->assert Equals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );208 $this->assert Equals( $this->post_data_overrides[ $name ], $setting->value() );205 $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods). 206 $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods). 207 $this->assertSame( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) ); 208 $this->assertSame( $this->post_data_overrides[ $name ], $setting->value() ); 209 209 } 210 210 } … … 226 226 $default = "default_value_{$name}"; 227 227 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 228 $this->assert Equals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );229 $this->assert Equals( $default, $setting->value() );228 $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) ); 229 $this->assertSame( $default, $setting->value() ); 230 230 $this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because setting is not in DB." ); 231 231 $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); 232 232 $this->assertArrayHasKey( 'foo', $base_value ); 233 $this->assert Equals( $default, $base_value['foo'] );233 $this->assertSame( $default, $base_value['foo'] ); 234 234 235 235 // Multidimensional: See what effect the preview has on an extant setting (default value should not be seen) without post value. … … 245 245 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 246 246 $base_value = call_user_func( $type_options['getter'], $base_name, array() ); 247 $this->assert Equals( $initial_value, $base_value['foo'] );248 $this->assert Equals( $initial_value, $setting->value() );247 $this->assertSame( $initial_value, $base_value['foo'] ); 248 $this->assertSame( $initial_value, $setting->value() ); 249 249 $this->assertFalse( $setting->preview(), "Preview for $setting->id should no-op because setting is in DB and post value is absent." ); 250 $this->assert Equals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).251 $this->assert Equals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).250 $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods). 251 $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods). 252 252 $base_value = call_user_func( $type_options['getter'], $base_name, array() ); 253 $this->assert Equals( $initial_value, $base_value['foo'] );254 $this->assert Equals( $initial_value, $setting->value() );253 $this->assertSame( $initial_value, $base_value['foo'] ); 254 $this->assertSame( $initial_value, $setting->value() ); 255 255 256 256 // Multidimensional: Ensure that setting a post value *after* preview() is called results in the post value being seen (deferred preview). … … 258 258 $this->manager->set_post_value( $setting->id, $override_value ); 259 259 $base_value = call_user_func( $type_options['getter'], $base_name, array() ); 260 $this->assert Equals( $override_value, $base_value['foo'] );261 $this->assert Equals( $override_value, $setting->value() );260 $this->assertSame( $override_value, $base_value['foo'] ); 261 $this->assertSame( $override_value, $setting->value() ); 262 262 263 263 // Multidimensional: Test unset setting being overridden by a post value. … … 266 266 $default = "default_value_{$name}"; 267 267 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 268 $this->assert Equals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );269 $this->assert Equals( $default, $setting->value() );268 $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) ); 269 $this->assertSame( $default, $setting->value() ); 270 270 $this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because a post value is present." ); 271 $this->assert Equals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).272 $this->assert Equals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).271 $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods). 272 $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods). 273 273 $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); 274 274 $this->assertArrayHasKey( 'foo', $base_value ); 275 $this->assert Equals( $this->post_data_overrides[ $name ], $base_value['foo'] );275 $this->assertSame( $this->post_data_overrides[ $name ], $base_value['foo'] ); 276 276 277 277 // Multidimensional: Test set setting being overridden by a post value. … … 289 289 $this->assertArrayHasKey( 'foo', $base_value ); 290 290 $this->assertArrayHasKey( 'bar', $base_value ); 291 $this->assert Equals( $base_initial_value['foo'], $base_value['foo'] );291 $this->assertSame( $base_initial_value['foo'], $base_value['foo'] ); 292 292 293 293 $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined ); 294 $this->assert Equals( $base_initial_value['bar'], $getter['bar'] );295 $this->assert Equals( $initial_value, $setting->value() );294 $this->assertSame( $base_initial_value['bar'], $getter['bar'] ); 295 $this->assertSame( $initial_value, $setting->value() ); 296 296 $this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because post value is present." ); 297 $this->assert Equals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).298 $this->assert Equals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).297 $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods). 298 $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods). 299 299 $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); 300 300 $this->assertArrayHasKey( 'foo', $base_value ); 301 $this->assert Equals( $this->post_data_overrides[ $name ], $base_value['foo'] );301 $this->assertSame( $this->post_data_overrides[ $name ], $base_value['foo'] ); 302 302 $this->assertArrayHasKey( 'bar', call_user_func( $type_options['getter'], $base_name, $this->undefined ) ); 303 303 304 304 $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined ); 305 $this->assert Equals( $base_initial_value['bar'], $getter['bar'] );305 $this->assertSame( $base_initial_value['bar'], $getter['bar'] ); 306 306 } 307 307 } … … 344 344 $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); 345 345 $id_data = $setting->id_data(); 346 $this->assert Equals( $name, $id_data['base'] );346 $this->assertSame( $name, $id_data['base'] ); 347 347 return $this->custom_type_getter( $name, $default ); 348 348 } … … 382 382 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 383 383 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 384 $this->assert Equals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );385 $this->assert Equals( $default, $setting->value() );384 $this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); 385 $this->assertSame( $default, $setting->value() ); 386 386 $this->assertTrue( $setting->preview() ); 387 $this->assert Equals( 1, did_action( "customize_preview_{$setting->id}" ) );388 $this->assert Equals( 1, did_action( "customize_preview_{$setting->type}" ) );389 $this->assert Equals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default.390 $this->assert Equals( $default, $setting->value() ); // Should be same as above.387 $this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ) ); 388 $this->assertSame( 1, did_action( "customize_preview_{$setting->type}" ) ); 389 $this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default. 390 $this->assertSame( $default, $setting->value() ); // Should be same as above. 391 391 392 392 // Custom type existing and no post value override. … … 398 398 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 399 399 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 400 $this->assert Equals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );401 $this->assert Equals( $initial_value, $setting->value() );400 $this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); 401 $this->assertSame( $initial_value, $setting->value() ); 402 402 $this->assertFalse( $setting->preview(), "Preview for $setting->id should not apply because existing type without an override." ); 403 $this->assert Equals( 0, did_action( "customize_preview_{$setting->id}" ), 'Zero preview actions because initial value is set with no incoming post value, so there is no preview to apply.' );404 $this->assert Equals( 1, did_action( "customize_preview_{$setting->type}" ) );405 $this->assert Equals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.406 $this->assert Equals( $initial_value, $setting->value() ); // Should be same as above.403 $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ), 'Zero preview actions because initial value is set with no incoming post value, so there is no preview to apply.' ); 404 $this->assertSame( 1, did_action( "customize_preview_{$setting->type}" ) ); 405 $this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above. 406 $this->assertSame( $initial_value, $setting->value() ); // Should be same as above. 407 407 408 408 // Custom type deferred preview (setting post value after preview ran). 409 409 $override_value = "custom_type_value_{$name}_override_deferred_preview"; 410 410 $this->manager->set_post_value( $setting->id, $override_value ); 411 $this->assert Equals( $override_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.412 $this->assert Equals( $override_value, $setting->value() ); // Should be same as above.411 $this->assertSame( $override_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above. 412 $this->assertSame( $override_value, $setting->value() ); // Should be same as above. 413 413 414 414 // Custom type not existing and with a post value override. … … 418 418 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 419 419 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 420 $this->assert Equals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );421 $this->assert Equals( $default, $setting->value() );420 $this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); 421 $this->assertSame( $default, $setting->value() ); 422 422 $this->assertTrue( $setting->preview() ); 423 $this->assert Equals( 1, did_action( "customize_preview_{$setting->id}" ), 'One preview action now because initial value was not set and/or there is no incoming post value, so there is is a preview to apply.' );424 $this->assert Equals( 3, did_action( "customize_preview_{$setting->type}" ) );425 $this->assert Equals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );426 $this->assert Equals( $post_data_overrides[ $name ], $setting->value() );423 $this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ), 'One preview action now because initial value was not set and/or there is no incoming post value, so there is is a preview to apply.' ); 424 $this->assertSame( 3, did_action( "customize_preview_{$setting->type}" ) ); 425 $this->assertSame( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) ); 426 $this->assertSame( $post_data_overrides[ $name ], $setting->value() ); 427 427 428 428 // Custom type not existing and with a post value override. … … 434 434 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 435 435 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 436 $this->assert Equals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );437 $this->assert Equals( $initial_value, $setting->value() );436 $this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); 437 $this->assertSame( $initial_value, $setting->value() ); 438 438 $this->assertTrue( $setting->preview() ); 439 $this->assert Equals( 1, did_action( "customize_preview_{$setting->id}" ) );440 $this->assert Equals( 4, did_action( "customize_preview_{$setting->type}" ) );441 $this->assert Equals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );442 $this->assert Equals( $post_data_overrides[ $name ], $setting->value() );439 $this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ) ); 440 $this->assertSame( 4, did_action( "customize_preview_{$setting->type}" ) ); 441 $this->assertSame( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) ); 442 $this->assertSame( $post_data_overrides[ $name ], $setting->value() ); 443 443 444 444 // Custom type that does not handle supplying the post value from the customize_value_{$id_base} filter. … … 479 479 $default = "default_value_{$name}"; 480 480 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 481 $this->assert Equals( $this->undefined, get_option( $name, $this->undefined ) );482 $this->assert Equals( $default, $setting->value() );481 $this->assertSame( $this->undefined, get_option( $name, $this->undefined ) ); 482 $this->assertSame( $default, $setting->value() ); 483 483 $this->assertTrue( $setting->preview() ); 484 $this->assert Equals( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) );485 $this->assert Equals( $default, $setting->value() );484 $this->assertSame( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) ); 485 $this->assertSame( $default, $setting->value() ); 486 486 } 487 487 … … 528 528 */ 529 529 function handle_customize_update_custom_foo_action( $value, $setting = null ) { 530 $this->assert Equals( 'hello world \\o/', $value );530 $this->assertSame( 'hello world \\o/', $value ); 531 531 $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); 532 532 } … … 540 540 function handle_customize_save_custom_foo_action( $setting ) { 541 541 $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); 542 $this->assert Equals( 'custom', $setting->type );543 $this->assert Equals( 'foo', $setting->id );542 $this->assertSame( 'custom', $setting->type ); 543 $this->assertSame( 'foo', $setting->id ); 544 544 } 545 545 … … 562 562 $this->assertTrue( $setting->is_current_blog_previewed() ); 563 563 564 $this->assert Equals( $post_value, $setting->value() );565 $this->assert Equals( $post_value, get_option( $name ) );564 $this->assertSame( $post_value, $setting->value() ); 565 $this->assertSame( $post_value, get_option( $name ) ); 566 566 } 567 567 … … 611 611 $setting->save(); 612 612 $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) ); 613 $this->assert Equals( 'yes', $autoload );614 $this->assert Equals( $value, get_option( $name ) );613 $this->assertSame( 'yes', $autoload ); 614 $this->assertSame( $value, get_option( $name ) ); 615 615 616 616 $name = 'autoloaded2'; … … 627 627 $setting->save(); 628 628 $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) ); 629 $this->assert Equals( 'yes', $autoload );630 $this->assert Equals( $value, get_option( $name ) );629 $this->assertSame( 'yes', $autoload ); 630 $this->assertSame( $value, get_option( $name ) ); 631 631 632 632 $name = 'not-autoloaded1'; … … 643 643 $setting->save(); 644 644 $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) ); 645 $this->assert Equals( 'no', $autoload );646 $this->assert Equals( $value, get_option( $name ) );645 $this->assertSame( 'no', $autoload ); 646 $this->assertSame( $value, get_option( $name ) ); 647 647 648 648 $id_base = 'multi-not-autoloaded'; … … 666 666 $setting1->save(); 667 667 $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $id_base ) ); 668 $this->assert Equals( 'no', $autoload, 'Even though setting1 did not indicate autoload (thus normally true), since another multidimensional option setting of the base did say autoload=false, it should be autoload=no' );668 $this->assertSame( 'no', $autoload, 'Even though setting1 did not indicate autoload (thus normally true), since another multidimensional option setting of the base did say autoload=false, it should be autoload=no' ); 669 669 } 670 670 … … 686 686 $setting = new WP_Customize_Setting( $this->manager, 'name', $args ); 687 687 688 $this->assert Equals( $default, $setting->value() );689 $this->assert Equals( base64_encode( $default ), $setting->js_value() );688 $this->assertSame( $default, $setting->value() ); 689 $this->assertSame( base64_encode( $default ), $setting->js_value() ); 690 690 691 691 $exported = $setting->json(); … … 694 694 $this->assertArrayHasKey( 'transport', $exported ); 695 695 $this->assertArrayHasKey( 'dirty', $exported ); 696 $this->assert Equals( $setting->js_value(), $exported['value'] );697 $this->assert Equals( $args['type'], $setting->type );698 $this->assert Equals( $args['transport'], $setting->transport );699 $this->assert Equals( $args['dirty'], $setting->dirty );696 $this->assertSame( $setting->js_value(), $exported['value'] ); 697 $this->assertSame( $args['type'], $setting->type ); 698 $this->assertSame( $args['transport'], $setting->transport ); 699 $this->assertSame( $args['dirty'], $setting->dirty ); 700 700 } 701 701 … … 716 716 $validity = $setting->validate( 'BAD!' ); 717 717 $this->assertInstanceOf( 'WP_Error', $validity ); 718 $this->assert Equals( 'invalid_key', $validity->get_error_code() );718 $this->assertSame( 'invalid_key', $validity->get_error_code() ); 719 719 } 720 720 … … 757 757 758 758 $setting = new WP_Customize_Setting( $this->manager, $setting_id ); 759 $this->assert Equals( $initial_value, $setting->value() );759 $this->assertSame( $initial_value, $setting->value() ); 760 760 761 761 $override_value = -123456; … … 763 763 $setting->preview(); 764 764 765 $this->assert Equals( $override_value, $setting->value() );765 $this->assertSame( $override_value, $setting->value() ); 766 766 } 767 767 }
Note: See TracChangeset
for help on using the changeset viewer.