Changeset 48937 for trunk/tests/phpunit/tests/widgets/text-widget.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets/text-widget.php
r48858 r48937 49 49 function test_construct() { 50 50 $widget = new WP_Widget_Text(); 51 $this->assert Equals( 'text', $widget->id_base );52 $this->assert Equals( 'widget_text', $widget->widget_options['classname'] );51 $this->assertSame( 'text', $widget->id_base ); 52 $this->assertSame( 'widget_text', $widget->widget_options['classname'] ); 53 53 $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); 54 $this->assert Equals( 400, $widget->control_options['width'] );55 $this->assert Equals( 350, $widget->control_options['height'] );54 $this->assertSame( 400, $widget->control_options['width'] ); 55 $this->assertSame( 350, $widget->control_options['height'] ); 56 56 } 57 57 … … 66 66 $widget->_register(); 67 67 68 $this->assert Equals( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) );69 $this->assert Equals( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ) );68 $this->assertSame( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); 69 $this->assertSame( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ) ); 70 70 $this->assertContains( 'wp.textWidgets.idBases.push( "text" );', wp_scripts()->registered['text-widgets']->extra['after'] ); 71 71 $this->assertFalse( has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); … … 98 98 $widget = new WP_Widget_Text(); 99 99 $widget->_register(); 100 $this->assert Equals( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) );100 $this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); 101 101 } 102 102 … … 174 174 $this->assertContains( '<br />', $output ); 175 175 $this->assertNotEmpty( $this->widget_text_args ); 176 $this->assert Equals( $instance['text'], $this->widget_text_args[0] );177 $this->assert Equals( $instance, $this->widget_text_args[1] );178 $this->assert Equals( $widget, $this->widget_text_args[2] );176 $this->assertSame( $instance['text'], $this->widget_text_args[0] ); 177 $this->assertSame( $instance, $this->widget_text_args[1] ); 178 $this->assertSame( $widget, $this->widget_text_args[2] ); 179 179 $this->assertEmpty( $this->widget_text_content_args ); 180 180 $this->assertContains( '[filter:widget_text]', $output ); … … 201 201 $this->assertContains( '<br />', $output ); 202 202 $this->assertCount( 3, $this->widget_text_args ); 203 $this->assert Equals( $expected_instance['text'], $this->widget_text_args[0] );204 $this->assert Equals( $expected_instance, $this->widget_text_args[1] );205 $this->assert Equals( $widget, $this->widget_text_args[2] );203 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); 204 $this->assertSame( $expected_instance, $this->widget_text_args[1] ); 205 $this->assertSame( $widget, $this->widget_text_args[2] ); 206 206 $this->assertCount( 3, $this->widget_text_content_args ); 207 $this->assert Equals( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] );208 $this->assert Equals( $expected_instance, $this->widget_text_content_args[1] );209 $this->assert Equals( $widget, $this->widget_text_content_args[2] );207 $this->assertSame( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] ); 208 $this->assertSame( $expected_instance, $this->widget_text_content_args[1] ); 209 $this->assertSame( $widget, $this->widget_text_content_args[2] ); 210 210 $this->assertContains( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output ); 211 211 … … 225 225 $this->assertContains( '<br />', $output ); 226 226 $this->assertCount( 3, $this->widget_text_args ); 227 $this->assert Equals( $expected_instance['text'], $this->widget_text_args[0] );228 $this->assert Equals( $expected_instance, $this->widget_text_args[1] );229 $this->assert Equals( $widget, $this->widget_text_args[2] );227 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); 228 $this->assertSame( $expected_instance, $this->widget_text_args[1] ); 229 $this->assertSame( $widget, $this->widget_text_args[2] ); 230 230 $this->assertCount( 3, $this->widget_text_content_args ); 231 $this->assert Equals( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] );232 $this->assert Equals( $expected_instance, $this->widget_text_content_args[1] );233 $this->assert Equals( $widget, $this->widget_text_content_args[2] );231 $this->assertSame( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] ); 232 $this->assertSame( $expected_instance, $this->widget_text_content_args[1] ); 233 $this->assertSame( $widget, $this->widget_text_content_args[2] ); 234 234 $this->assertContains( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output ); 235 235 … … 249 249 $this->assertContains( '<br />', $output ); 250 250 $this->assertCount( 3, $this->widget_text_args ); 251 $this->assert Equals( $expected_instance['text'], $this->widget_text_args[0] );252 $this->assert Equals( $expected_instance, $this->widget_text_args[1] );253 $this->assert Equals( $widget, $this->widget_text_args[2] );251 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); 252 $this->assertSame( $expected_instance, $this->widget_text_args[1] ); 253 $this->assertSame( $widget, $this->widget_text_args[2] ); 254 254 $this->assertNull( $this->widget_text_content_args ); 255 255 $this->assertContains( wpautop( $expected_instance['text'] . '[filter:widget_text]' ), $output ); … … 270 270 $this->assertNotContains( '<br />', $output ); 271 271 $this->assertCount( 3, $this->widget_text_args ); 272 $this->assert Equals( $expected_instance['text'], $this->widget_text_args[0] );273 $this->assert Equals( $expected_instance, $this->widget_text_args[1] );274 $this->assert Equals( $widget, $this->widget_text_args[2] );272 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); 273 $this->assertSame( $expected_instance, $this->widget_text_args[1] ); 274 $this->assertSame( $widget, $this->widget_text_args[2] ); 275 275 $this->assertNull( $this->widget_text_content_args ); 276 276 $this->assertContains( $expected_instance['text'] . '[filter:widget_text]', $output ); … … 345 345 $widget->widget( $args, $instance ); 346 346 $output = ob_get_clean(); 347 $this->assert Equals( 1, $this->shortcode_render_count );347 $this->assertSame( 1, $this->shortcode_render_count ); 348 348 $this->assertNotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); 349 349 $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); … … 363 363 $widget->widget( $args, $instance ); 364 364 $output = ob_get_clean(); 365 $this->assert Equals( 1, $this->shortcode_render_count );365 $this->assertSame( 1, $this->shortcode_render_count ); 366 366 $this->assertNotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); 367 367 $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); … … 375 375 $widget->widget( $args, $instance ); 376 376 $output = ob_get_clean(); 377 $this->assert Equals( 1, $this->shortcode_render_count );377 $this->assertSame( 1, $this->shortcode_render_count ); 378 378 $this->assertNotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); 379 379 $this->assertContains( wpautop( $this->example_shortcode_content ), $output, 'Shortcode was applied *with* wpautop() applying to shortcode output since plugin used legacy filter.' ); … … 391 391 // Visual Text Widget with only core-added widget_text_content filter for do_shortcode(). 392 392 $this->assertFalse( has_filter( 'widget_text', 'do_shortcode' ) ); 393 $this->assert Equals( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'Expected core to have set do_shortcode as widget_text_content filter.' );393 $this->assertSame( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'Expected core to have set do_shortcode as widget_text_content filter.' ); 394 394 $this->shortcode_render_count = 0; 395 395 ob_start(); 396 396 $widget->widget( $args, $instance ); 397 397 $output = ob_get_clean(); 398 $this->assert Equals( 1, $this->shortcode_render_count );398 $this->assertSame( 1, $this->shortcode_render_count ); 399 399 $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); 400 400 $this->assertNotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); 401 401 $this->assertFalse( has_filter( 'widget_text', 'do_shortcode' ), 'The widget_text filter still lacks do_shortcode handler.' ); 402 $this->assert Equals( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'The widget_text_content filter still has do_shortcode handler.' );402 $this->assertSame( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'The widget_text_content filter still has do_shortcode handler.' ); 403 403 $this->assertNull( $this->post_during_shortcode ); 404 404 … … 409 409 $widget->widget( $args, $instance ); 410 410 $output = ob_get_clean(); 411 $this->assert Equals( 1, $this->shortcode_render_count );411 $this->assertSame( 1, $this->shortcode_render_count ); 412 412 $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); 413 413 $this->assertNotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); 414 $this->assert Equals( 10, has_filter( 'widget_text', 'do_shortcode' ), 'Expected do_shortcode to be restored to widget_text.' );414 $this->assertSame( 10, has_filter( 'widget_text', 'do_shortcode' ), 'Expected do_shortcode to be restored to widget_text.' ); 415 415 $this->assertNull( $this->post_during_shortcode ); 416 416 $this->assertNull( $this->post_during_shortcode ); … … 424 424 $widget->widget( $args, $instance ); 425 425 $output = ob_get_clean(); 426 $this->assert Equals( 0, $this->shortcode_render_count );426 $this->assertSame( 0, $this->shortcode_render_count ); 427 427 $this->assertContains( '[example]', $output ); 428 428 $this->assertNotContains( $this->example_shortcode_content, $output ); … … 731 731 ); 732 732 $result = $widget->update( $instance, array() ); 733 $this->assert Equals( $expected, $result );733 $this->assertSame( $expected, $result ); 734 734 $this->assertTrue( ! empty( $expected['filter'] ), 'Expected filter prop to be truthy, to handle case where 4.8 is downgraded to 4.7.' ); 735 735 … … 739 739 $expected['text'] = $instance['text']; 740 740 $result = $widget->update( $instance, array() ); 741 $this->assert Equals( $expected, $result, 'KSES should apply as expected.' );741 $this->assertSame( $expected, $result, 'KSES should apply as expected.' ); 742 742 remove_filter( 'map_meta_cap', array( $this, 'grant_unfiltered_html_cap' ) ); 743 743 … … 747 747 $expected['text'] = wp_kses_post( $instance['text'] ); 748 748 $result = $widget->update( $instance, array() ); 749 $this->assert Equals( $expected, $result, 'KSES should not apply since user can unfiltered_html.' );749 $this->assertSame( $expected, $result, 'KSES should not apply since user can unfiltered_html.' ); 750 750 remove_filter( 'map_meta_cap', array( $this, 'revoke_unfiltered_html_cap' ), 10 ); 751 751 } … … 766 766 ); 767 767 $result = $widget->update( $instance, array() ); 768 $this->assert Equals( $instance, $result, 'Updating a widget without visual prop and explicit filter=false leaves visual prop absent' );768 $this->assertSame( $instance, $result, 'Updating a widget without visual prop and explicit filter=false leaves visual prop absent' ); 769 769 770 770 // -- … … 775 775 ); 776 776 $result = $widget->update( $instance, array() ); 777 $this->assert Equals( $instance, $result, 'Updating a widget without visual prop and explicit filter=true leaves legacy prop absent.' );777 $this->assertSame( $instance, $result, 'Updating a widget without visual prop and explicit filter=true leaves legacy prop absent.' ); 778 778 779 779 // -- … … 796 796 ); 797 797 $result = $widget->update( $instance, $old_instance ); 798 $this->assert Equals( $expected, $result, 'Updating a pre-existing widget with visual mode forces filter to be true.' );798 $this->assertSame( $expected, $result, 'Updating a pre-existing widget with visual mode forces filter to be true.' ); 799 799 800 800 // -- … … 817 817 ) 818 818 ); 819 $this->assert Equals( $expected, $result, 'Updating a pre-existing visual widget retains visual mode when updated.' );819 $this->assertSame( $expected, $result, 'Updating a pre-existing visual widget retains visual mode when updated.' ); 820 820 821 821 // -- … … 838 838 ) 839 839 ); 840 $this->assert Equals( $expected, $result, 'Updating a pre-existing visual widget retains visual=true and supplies missing filter=true.' );840 $this->assertSame( $expected, $result, 'Updating a pre-existing visual widget retains visual=true and supplies missing filter=true.' ); 841 841 842 842 // -- … … 891 891 ) 892 892 ); 893 $this->assert Equals( $expected, $result, 'Updating a widget that previously had legacy form results in filter allowed to be false.' );893 $this->assertSame( $expected, $result, 'Updating a widget that previously had legacy form results in filter allowed to be false.' ); 894 894 895 895 // -- … … 907 907 ) 908 908 ); 909 $this->assert Equals( $expected, $result, 'Updating a widget that had \'content\' as its filter value persists non-legacy mode. This only existed in WP 4.8.0.' );909 $this->assertSame( $expected, $result, 'Updating a widget that had \'content\' as its filter value persists non-legacy mode. This only existed in WP 4.8.0.' ); 910 910 911 911 // -- … … 944 944 ) 945 945 ); 946 $this->assert Equals( $expected, $result, 'Updating a widget with filter=content (from WP 4.8.0) upgrades to filter=true&visual=true.' );946 $this->assertSame( $expected, $result, 'Updating a widget with filter=content (from WP 4.8.0) upgrades to filter=true&visual=true.' ); 947 947 } 948 948
Note: See TracChangeset
for help on using the changeset viewer.