Changeset 48937 for trunk/tests/phpunit/tests/customize/widgets.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/widgets.php
r47198 r48937 39 39 $widget_categories = get_option( 'widget_categories' ); 40 40 $this->assertArrayHasKey( 2, $widget_categories ); 41 $this->assert Equals( '', $widget_categories[2]['title'] );41 $this->assertSame( '', $widget_categories[2]['title'] ); 42 42 43 43 $this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars']; … … 91 91 function test_construct() { 92 92 $this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets ); 93 $this->assert Equals( $this->manager, $this->manager->widgets->manager );93 $this->assertSame( $this->manager, $this->manager->widgets->manager ); 94 94 } 95 95 … … 106 106 register_sidebar( array( 'id' => $sidebar_id ) ); 107 107 $this->manager->widgets->customize_register(); 108 $this->assert Equals( array_fill_keys( array( 'wp_inactive_widgets', $sidebar_id ), array() ), wp_get_sidebars_widgets() );108 $this->assertSame( array_fill_keys( array( 'wp_inactive_widgets', $sidebar_id ), array() ), wp_get_sidebars_widgets() ); 109 109 } 110 110 … … 122 122 $selective_refreshable_widgets = $this->manager->widgets->get_selective_refreshable_widgets(); 123 123 $this->assertInternalType( 'array', $selective_refreshable_widgets ); 124 $this->assert Equals( count( $wp_widget_factory->widgets ), count( $selective_refreshable_widgets ) );124 $this->assertSame( count( $wp_widget_factory->widgets ), count( $selective_refreshable_widgets ) ); 125 125 $this->assertArrayHasKey( 'text', $selective_refreshable_widgets ); 126 126 $this->assertTrue( $selective_refreshable_widgets['text'] ); … … 207 207 $setting = $this->manager->get_setting( 'widget_categories[2]' ); 208 208 $this->assertNotEmpty( $setting, 'Expected setting for pre-existing widget category-2, being customized.' ); 209 $this->assert Equals( $expected_transport, $setting->transport );209 $this->assertSame( $expected_transport, $setting->transport ); 210 210 211 211 $setting = $this->manager->get_setting( 'widget_search[2]' ); 212 212 $this->assertNotEmpty( $setting, 'Expected setting for pre-existing widget search-2, not being customized.' ); 213 $this->assert Equals( $expected_transport, $setting->transport );213 $this->assertSame( $expected_transport, $setting->transport ); 214 214 215 215 $setting = $this->manager->get_setting( 'widget_search[3]' ); 216 216 $this->assertNotEmpty( $setting, 'Expected dynamic setting for non-existing widget search-3, being customized.' ); 217 $this->assert Equals( $expected_transport, $setting->transport );217 $this->assertSame( $expected_transport, $setting->transport ); 218 218 219 219 $widget_categories = get_option( 'widget_categories' ); 220 $this->assert Equals( $raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.' );220 $this->assertSame( $raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.' ); 221 221 } 222 222 … … 268 268 $args = $this->manager->widgets->get_setting_args( 'widget_foo[2]' ); 269 269 foreach ( $default_args as $key => $default_value ) { 270 $this->assert Equals( $default_value, $args[ $key ] );271 } 272 $this->assert Equals( 'WIDGET_FOO[2]', $args['uppercase_id_set_by_filter'] );270 $this->assertSame( $default_value, $args[ $key ] ); 271 } 272 $this->assertSame( 'WIDGET_FOO[2]', $args['uppercase_id_set_by_filter'] ); 273 273 274 274 $default_args = array( … … 282 282 $args = $this->manager->widgets->get_setting_args( 'widget_search[2]' ); 283 283 foreach ( $default_args as $key => $default_value ) { 284 $this->assert Equals( $default_value, $args[ $key ] );284 $this->assertSame( $default_value, $args[ $key ] ); 285 285 } 286 286 287 287 remove_theme_support( 'customize-selective-refresh-widgets' ); 288 288 $args = $this->manager->widgets->get_setting_args( 'widget_search[2]' ); 289 $this->assert Equals( 'refresh', $args['transport'] );289 $this->assertSame( 'refresh', $args['transport'] ); 290 290 add_theme_support( 'customize-selective-refresh-widgets' ); 291 291 … … 300 300 $args = $this->manager->widgets->get_setting_args( 'widget_bar[3]', $override_args ); 301 301 foreach ( $override_args as $key => $override_value ) { 302 $this->assert Equals( $override_value, $args[ $key ] );303 } 304 $this->assert Equals( 'WIDGET_BAR[3]', $args['uppercase_id_set_by_filter'] );302 $this->assertSame( $override_value, $args[ $key ] ); 303 } 304 $this->assertSame( 'WIDGET_BAR[3]', $args['uppercase_id_set_by_filter'] ); 305 305 306 306 $default_args = array( … … 314 314 $args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-1]' ); 315 315 foreach ( $default_args as $key => $default_value ) { 316 $this->assert Equals( $default_value, $args[ $key ] );317 } 318 $this->assert Equals( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] );316 $this->assertSame( $default_value, $args[ $key ] ); 317 } 318 $this->assertSame( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] ); 319 319 320 320 $override_args = array( … … 328 328 $args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-2]', $override_args ); 329 329 foreach ( $override_args as $key => $override_value ) { 330 $this->assert Equals( $override_value, $args[ $key ] );331 } 332 $this->assert Equals( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] );330 $this->assertSame( $override_value, $args[ $key ] ); 331 } 332 $this->assertSame( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] ); 333 333 } 334 334 … … 354 354 $this->assertArrayHasKey( 'encoded_serialized_instance', $sanitized_for_js ); 355 355 $this->assertTrue( is_serialized( base64_decode( $sanitized_for_js['encoded_serialized_instance'] ), true ) ); 356 $this->assert Equals( $new_categories_instance['title'], $sanitized_for_js['title'] );356 $this->assertSame( $new_categories_instance['title'], $sanitized_for_js['title'] ); 357 357 $this->assertTrue( $sanitized_for_js['is_widget_customizer_js_value'] ); 358 358 $this->assertArrayHasKey( 'instance_hash_key', $sanitized_for_js ); … … 363 363 364 364 $unsanitized_from_js = $this->manager->widgets->sanitize_widget_instance( $sanitized_for_js ); 365 $this->assert Equals( $unsanitized_from_js, $new_categories_instance );365 $this->assertSame( $unsanitized_from_js, $new_categories_instance ); 366 366 } 367 367 … … 426 426 $params = $control->json(); 427 427 428 $this->assert Equals( 'widget_form', $params['type'] );428 $this->assertSame( 'widget_form', $params['type'] ); 429 429 $this->assertRegExp( '#^<li[^>]+>\s*</li>$#', $params['content'] ); 430 430 $this->assertRegExp( '#^<div[^>]*class=\'widget\'[^>]*#s', $params['widget_control'] ); … … 432 432 $this->assertNotContains( '<input class="widefat"', $params['widget_control'] ); 433 433 $this->assertContains( '<input class="widefat"', $params['widget_content'] ); 434 $this->assert Equals( 'search-2', $params['widget_id'] );435 $this->assert Equals( 'search', $params['widget_id_base'] );434 $this->assertSame( 'search-2', $params['widget_id'] ); 435 $this->assertSame( 'search', $params['widget_id_base'] ); 436 436 $this->assertArrayHasKey( 'sidebar_id', $params ); 437 437 $this->assertArrayHasKey( 'width', $params ); … … 497 497 $this->assertArrayHasKey( 'instance', $result ); 498 498 $this->assertArrayHasKey( 'form', $result ); 499 $this->assert Equals( $instance, $result['instance'] );499 $this->assertSame( $instance, $result['instance'] ); 500 500 $this->assertContains( sprintf( 'value="%s"', esc_attr( $instance['title'] ) ), $result['form'] ); 501 501 … … 508 508 $this->assertArrayHasKey( 'instance_hash_key', $post_value ); 509 509 $this->assertArrayHasKey( 'is_widget_customizer_js_value', $post_value ); 510 $this->assert Equals( $post_value, $this->manager->widgets->sanitize_widget_js_instance( $instance ) );510 $this->assertSame( $post_value, $this->manager->widgets->sanitize_widget_js_instance( $instance ) ); 511 511 } 512 512 … … 521 521 $args = apply_filters( 'customize_dynamic_partial_args', false, 'widget[search-2]' ); 522 522 $this->assertInternalType( 'array', $args ); 523 $this->assert Equals( 'widget', $args['type'] );524 $this->assert Equals( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] );523 $this->assertSame( 'widget', $args['type'] ); 524 $this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); 525 525 $this->assertTrue( $args['container_inclusive'] ); 526 526 527 527 $args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'widget[search-2]' ); 528 528 $this->assertInternalType( 'array', $args ); 529 $this->assert Equals( 'widget', $args['type'] );530 $this->assert Equals( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] );529 $this->assertSame( 'widget', $args['type'] ); 530 $this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); 531 531 $this->assertTrue( $args['container_inclusive'] ); 532 532 $this->assertFalse( $args['fallback_refresh'] ); … … 545 545 add_theme_support( 'customize-selective-refresh-widgets' ); 546 546 $this->manager->widgets->selective_refresh_init(); 547 $this->assert Equals( 10, has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) );548 $this->assert Equals( 10, has_action( 'dynamic_sidebar_after', array( $this->manager->widgets, 'end_dynamic_sidebar' ) ) );549 $this->assert Equals( 10, has_filter( 'dynamic_sidebar_params', array( $this->manager->widgets, 'filter_dynamic_sidebar_params' ) ) );550 $this->assert Equals( 10, has_filter( 'wp_kses_allowed_html', array( $this->manager->widgets, 'filter_wp_kses_allowed_data_attributes' ) ) );547 $this->assertSame( 10, has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) ); 548 $this->assertSame( 10, has_action( 'dynamic_sidebar_after', array( $this->manager->widgets, 'end_dynamic_sidebar' ) ) ); 549 $this->assertSame( 10, has_filter( 'dynamic_sidebar_params', array( $this->manager->widgets, 'filter_dynamic_sidebar_params' ) ) ); 550 $this->assertSame( 10, has_filter( 'wp_kses_allowed_html', array( $this->manager->widgets, 'filter_wp_kses_allowed_data_attributes' ) ) ); 551 551 } 552 552 … … 604 604 array(), 605 605 ); 606 $this->assert Equals( $params, $this->manager->widgets->filter_dynamic_sidebar_params( $params ), 'Expected short-circuit if not called after dynamic_sidebar_before.' );606 $this->assertSame( $params, $this->manager->widgets->filter_dynamic_sidebar_params( $params ), 'Expected short-circuit if not called after dynamic_sidebar_before.' ); 607 607 608 608 ob_start(); 609 609 do_action( 'dynamic_sidebar_before', 'foo' ); 610 610 $output = ob_get_clean(); 611 $this->assert Equals( '<!--dynamic_sidebar_before:foo:1-->', trim( $output ) );611 $this->assertSame( '<!--dynamic_sidebar_before:foo:1-->', trim( $output ) ); 612 612 613 613 $bad_params = $params; 614 614 unset( $bad_params[0]['id'] ); 615 $this->assert Equals( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) );615 $this->assertSame( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); 616 616 617 617 $bad_params = $params; 618 618 $bad_params[0]['id'] = 'non-existing'; 619 $this->assert Equals( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) );619 $this->assertSame( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); 620 620 621 621 $bad_params = $params; 622 622 $bad_params[0]['before_widget'] = ' <oops>'; 623 $this->assert Equals( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) );623 $this->assertSame( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); 624 624 625 625 $filtered_params = $this->manager->widgets->filter_dynamic_sidebar_params( $params ); … … 628 628 do_action( 'dynamic_sidebar_after', 'foo' ); 629 629 $output = ob_get_clean(); 630 $this->assert Equals( '<!--dynamic_sidebar_after:foo:1-->', trim( $output ) );630 $this->assertSame( '<!--dynamic_sidebar_after:foo:1-->', trim( $output ) ); 631 631 632 632 $output = wp_kses_post( $filtered_params[0]['before_widget'] ); … … 649 649 $this->assertNotEmpty( $partials ); 650 650 $partial = array_shift( $partials ); 651 $this->assert Equals( $partial_id, $partial->id );651 $this->assertSame( $partial_id, $partial->id ); 652 652 653 653 $this->assertFalse( $this->manager->widgets->render_widget_partial( $partial, array() ) ); … … 656 656 $output = $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'sidebar-1' ) ); 657 657 658 $this->assert Equals( 1, substr_count( $output, 'data-customize-partial-id' ) );659 $this->assert Equals( 1, substr_count( $output, 'data-customize-partial-type="widget"' ) );658 $this->assertSame( 1, substr_count( $output, 'data-customize-partial-id' ) ); 659 $this->assertSame( 1, substr_count( $output, 'data-customize-partial-type="widget"' ) ); 660 660 $this->assertContains( ' id="search-2"', $output ); 661 661 }
Note: See TracChangeset
for help on using the changeset viewer.