Changeset 51462 for trunk/tests/phpunit/tests/widgets/text-widget.php
- Timestamp:
- 07/19/2021 02:00:11 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets/text-widget.php
r51220 r51462 154 154 $widget->widget( $args, $instance ); 155 155 $output = ob_get_clean(); 156 $this->assert NotContains( '<p>', $output );157 $this->assert NotContains( '<br />', $output );156 $this->assertStringNotContainsString( '<p>', $output ); 157 $this->assertStringNotContainsString( '<br />', $output ); 158 158 $this->assertEmpty( $this->widget_text_content_args ); 159 159 $this->assertNotEmpty( $this->widget_text_args ); 160 $this->assert Contains( '[filter:widget_text]', $output );161 $this->assert NotContains( '[filter:widget_text_content]', $output );160 $this->assertStringContainsString( '[filter:widget_text]', $output ); 161 $this->assertStringNotContainsString( '[filter:widget_text_content]', $output ); 162 162 163 163 // Test with filter=true, implicit legacy mode. … … 171 171 $widget->widget( $args, $instance ); 172 172 $output = ob_get_clean(); 173 $this->assert Contains( '<p>', $output );174 $this->assert Contains( '<br />', $output );173 $this->assertStringContainsString( '<p>', $output ); 174 $this->assertStringContainsString( '<br />', $output ); 175 175 $this->assertNotEmpty( $this->widget_text_args ); 176 176 $this->assertSame( $instance['text'], $this->widget_text_args[0] ); … … 178 178 $this->assertSame( $widget, $this->widget_text_args[2] ); 179 179 $this->assertEmpty( $this->widget_text_content_args ); 180 $this->assert Contains( '[filter:widget_text]', $output );181 $this->assert NotContains( '[filter:widget_text_content]', $output );180 $this->assertStringContainsString( '[filter:widget_text]', $output ); 181 $this->assertStringNotContainsString( '[filter:widget_text_content]', $output ); 182 182 183 183 // Test with filter=content, the upgraded widget, in 4.8.0 only. … … 198 198 $widget->widget( $args, $instance ); 199 199 $output = ob_get_clean(); 200 $this->assert Contains( '<p>', $output );201 $this->assert Contains( '<br />', $output );200 $this->assertStringContainsString( '<p>', $output ); 201 $this->assertStringContainsString( '<br />', $output ); 202 202 $this->assertCount( 3, $this->widget_text_args ); 203 203 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); … … 208 208 $this->assertSame( $expected_instance, $this->widget_text_content_args[1] ); 209 209 $this->assertSame( $widget, $this->widget_text_content_args[2] ); 210 $this->assert Contains( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output );210 $this->assertStringContainsString( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output ); 211 211 212 212 // Test with filter=true&visual=true, the upgraded widget, in 4.8.1 and above. … … 222 222 $widget->widget( $args, $instance ); 223 223 $output = ob_get_clean(); 224 $this->assert Contains( '<p>', $output );225 $this->assert Contains( '<br />', $output );224 $this->assertStringContainsString( '<p>', $output ); 225 $this->assertStringContainsString( '<br />', $output ); 226 226 $this->assertCount( 3, $this->widget_text_args ); 227 227 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); … … 232 232 $this->assertSame( $expected_instance, $this->widget_text_content_args[1] ); 233 233 $this->assertSame( $widget, $this->widget_text_content_args[2] ); 234 $this->assert Contains( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output );234 $this->assertStringContainsString( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output ); 235 235 236 236 // Test with filter=true&visual=true, the upgraded widget, in 4.8.1 and above. … … 246 246 $widget->widget( $args, $instance ); 247 247 $output = ob_get_clean(); 248 $this->assert Contains( '<p>', $output );249 $this->assert Contains( '<br />', $output );248 $this->assertStringContainsString( '<p>', $output ); 249 $this->assertStringContainsString( '<br />', $output ); 250 250 $this->assertCount( 3, $this->widget_text_args ); 251 251 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); … … 253 253 $this->assertSame( $widget, $this->widget_text_args[2] ); 254 254 $this->assertNull( $this->widget_text_content_args ); 255 $this->assert Contains( wpautop( $expected_instance['text'] . '[filter:widget_text]' ), $output );255 $this->assertStringContainsString( wpautop( $expected_instance['text'] . '[filter:widget_text]' ), $output ); 256 256 257 257 // Test with filter=false&visual=false, the upgraded widget, in 4.8.1 and above. … … 267 267 $widget->widget( $args, $instance ); 268 268 $output = ob_get_clean(); 269 $this->assert NotContains( '<p>', $output );270 $this->assert NotContains( '<br />', $output );269 $this->assertStringNotContainsString( '<p>', $output ); 270 $this->assertStringNotContainsString( '<br />', $output ); 271 271 $this->assertCount( 3, $this->widget_text_args ); 272 272 $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); … … 274 274 $this->assertSame( $widget, $this->widget_text_args[2] ); 275 275 $this->assertNull( $this->widget_text_content_args ); 276 $this->assert Contains( $expected_instance['text'] . '[filter:widget_text]', $output );276 $this->assertStringContainsString( $expected_instance['text'] . '[filter:widget_text]', $output ); 277 277 } 278 278 … … 346 346 $output = ob_get_clean(); 347 347 $this->assertSame( 1, $this->shortcode_render_count ); 348 $this->assert NotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' );349 $this->assert Contains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' );350 $this->assert NotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' );348 $this->assertStringNotContainsString( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); 349 $this->assertStringContainsString( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); 350 $this->assertStringNotContainsString( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); 351 351 $this->assertNull( $this->post_during_shortcode ); 352 352 … … 364 364 $output = ob_get_clean(); 365 365 $this->assertSame( 1, $this->shortcode_render_count ); 366 $this->assert NotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' );367 $this->assert Contains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' );368 $this->assert NotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' );366 $this->assertStringNotContainsString( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); 367 $this->assertStringContainsString( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); 368 $this->assertStringNotContainsString( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); 369 369 $this->assertNull( $this->post_during_shortcode ); 370 370 … … 376 376 $output = ob_get_clean(); 377 377 $this->assertSame( 1, $this->shortcode_render_count ); 378 $this->assert NotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' );379 $this->assert Contains( wpautop( $this->example_shortcode_content ), $output, 'Shortcode was applied *with* wpautop() applying to shortcode output since plugin used legacy filter.' );378 $this->assertStringNotContainsString( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); 379 $this->assertStringContainsString( wpautop( $this->example_shortcode_content ), $output, 'Shortcode was applied *with* wpautop() applying to shortcode output since plugin used legacy filter.' ); 380 380 $this->assertNull( $this->post_during_shortcode ); 381 381 remove_filter( 'widget_text', 'do_shortcode' ); … … 397 397 $output = ob_get_clean(); 398 398 $this->assertSame( 1, $this->shortcode_render_count ); 399 $this->assert Contains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' );400 $this->assert NotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' );399 $this->assertStringContainsString( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); 400 $this->assertStringNotContainsString( '<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 402 $this->assertSame( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'The widget_text_content filter still has do_shortcode handler.' ); … … 410 410 $output = ob_get_clean(); 411 411 $this->assertSame( 1, $this->shortcode_render_count ); 412 $this->assert Contains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' );413 $this->assert NotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' );412 $this->assertStringContainsString( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); 413 $this->assertStringNotContainsString( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); 414 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 ); … … 425 425 $output = ob_get_clean(); 426 426 $this->assertSame( 0, $this->shortcode_render_count ); 427 $this->assert Contains( '[example]', $output );428 $this->assert NotContains( $this->example_shortcode_content, $output );427 $this->assertStringContainsString( '[example]', $output ); 428 $this->assertStringNotContainsString( $this->example_shortcode_content, $output ); 429 429 $this->assertFalse( has_filter( 'widget_text', 'do_shortcode' ) ); 430 430 $this->assertFalse( has_filter( 'widget_text_content', 'do_shortcode' ) ); … … 645 645 $widget->form( $instance ); 646 646 $form = ob_get_clean(); 647 $this->assert Contains( 'class="visual" type="hidden" value=""', $form );648 $this->assert NotContains( 'class="visual sync-input" type="hidden" value="on"', $form );647 $this->assertStringContainsString( 'class="visual" type="hidden" value=""', $form ); 648 $this->assertStringNotContainsString( 'class="visual sync-input" type="hidden" value="on"', $form ); 649 649 650 650 $instance = array( … … 657 657 $widget->form( $instance ); 658 658 $form = ob_get_clean(); 659 $this->assert Contains( 'class="visual sync-input" type="hidden" value="on"', $form );660 $this->assert NotContains( 'class="visual sync-input" type="hidden" value=""', $form );659 $this->assertStringContainsString( 'class="visual sync-input" type="hidden" value="on"', $form ); 660 $this->assertStringNotContainsString( 'class="visual sync-input" type="hidden" value=""', $form ); 661 661 662 662 $instance = array( … … 669 669 $widget->form( $instance ); 670 670 $form = ob_get_clean(); 671 $this->assert Contains( 'class="visual sync-input" type="hidden" value="on"', $form );672 $this->assert NotContains( 'class="visual sync-input" type="hidden" value=""', $form );671 $this->assertStringContainsString( 'class="visual sync-input" type="hidden" value="on"', $form ); 672 $this->assertStringNotContainsString( 'class="visual sync-input" type="hidden" value=""', $form ); 673 673 674 674 $instance = array( … … 682 682 $widget->form( $instance ); 683 683 $form = ob_get_clean(); 684 $this->assert Contains( 'class="visual sync-input" type="hidden" value="on"', $form );685 $this->assert Contains( '<code>&lt;strong&gt;BOLD!', $form );686 $this->assert NotContains( 'class="visual sync-input" type="hidden" value=""', $form );684 $this->assertStringContainsString( 'class="visual sync-input" type="hidden" value="on"', $form ); 685 $this->assertStringContainsString( '<code>&lt;strong&gt;BOLD!', $form ); 686 $this->assertStringNotContainsString( 'class="visual sync-input" type="hidden" value=""', $form ); 687 687 688 688 remove_filter( 'user_can_richedit', '__return_true' ); … … 698 698 $widget->form( $instance ); 699 699 $form = ob_get_clean(); 700 $this->assert NotContains( 'Evil:</textarea>', $form );701 $this->assert Contains( 'Evil:</textarea>', $form );700 $this->assertStringNotContainsString( 'Evil:</textarea>', $form ); 701 $this->assertStringContainsString( 'Evil:</textarea>', $form ); 702 702 } 703 703 … … 1000 1000 $output = ob_get_clean(); 1001 1001 1002 $this->assert Contains( '<script type="text/html" id="tmpl-widget-text-control-fields">', $output );1002 $this->assertStringContainsString( '<script type="text/html" id="tmpl-widget-text-control-fields">', $output ); 1003 1003 } 1004 1004 … … 1027 1027 $output = get_echo( array( $widget, 'widget' ), array( $args, $instance ) ); 1028 1028 1029 $this->assert Contains( 'rel="noopener"', $output );1029 $this->assertStringContainsString( 'rel="noopener"', $output ); 1030 1030 } 1031 1031 … … 1054 1054 $output = get_echo( array( $widget, 'widget' ), array( $args, $instance ) ); 1055 1055 1056 $this->assert NotContains( 'rel="noopener"', $output );1056 $this->assertStringNotContainsString( 'rel="noopener"', $output ); 1057 1057 } 1058 1058 }
Note: See TracChangeset
for help on using the changeset viewer.