Changeset 41260 for trunk/tests/phpunit/tests/widgets/text-widget.php
- Timestamp:
- 08/17/2017 11:36:53 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/widgets/text-widget.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets/text-widget.php
r41251 r41260 448 448 */ 449 449 function test_form() { 450 $widget = new WP_Widget_Text(); 450 add_filter( 'user_can_richedit', '__return_true' ); 451 $widget = new WP_Widget_Text(); 452 $widget->_set( 2 ); 451 453 $instance = array( 452 454 'title' => 'Title', … … 460 462 $form = ob_get_clean(); 461 463 $this->assertContains( 'class="visual" type="hidden" value=""', $form ); 462 $this->assertNotContains( 'class="visual " type="hidden" value="on"', $form );464 $this->assertNotContains( 'class="visual sync-input" type="hidden" value="on"', $form ); 463 465 464 466 $instance = array( … … 471 473 $widget->form( $instance ); 472 474 $form = ob_get_clean(); 473 $this->assertContains( 'class="visual " type="hidden" value="on"', $form );474 $this->assertNotContains( 'class="visual " type="hidden" value=""', $form );475 $this->assertContains( 'class="visual sync-input" type="hidden" value="on"', $form ); 476 $this->assertNotContains( 'class="visual sync-input" type="hidden" value=""', $form ); 475 477 476 478 $instance = array( … … 483 485 $widget->form( $instance ); 484 486 $form = ob_get_clean(); 485 $this->assertContains( 'class="visual " type="hidden" value="on"', $form );486 $this->assertNotContains( 'class="visual " type="hidden" value=""', $form );487 488 $instance = array( 489 'title' => 'Title', 490 'text' => 'T ext',487 $this->assertContains( 'class="visual sync-input" type="hidden" value="on"', $form ); 488 $this->assertNotContains( 'class="visual sync-input" type="hidden" value=""', $form ); 489 490 $instance = array( 491 'title' => 'Title', 492 'text' => 'This is some HTML Code: <code><strong>BOLD!</strong></code>', 491 493 'filter' => true, 492 494 'visual' => true, … … 496 498 $widget->form( $instance ); 497 499 $form = ob_get_clean(); 498 $this->assertContains( 'class="visual" type="hidden" value="on"', $form ); 499 $this->assertNotContains( 'class="visual" type="hidden" value=""', $form ); 500 $this->assertContains( 'class="visual sync-input" type="hidden" value="on"', $form ); 501 $this->assertContains( '<code>&lt;strong&gt;BOLD!', $form ); 502 $this->assertNotContains( 'class="visual sync-input" type="hidden" value=""', $form ); 503 504 remove_filter( 'user_can_richedit', '__return_true' ); 505 add_filter( 'user_can_richedit', '__return_false' ); 506 $instance = array( 507 'title' => 'Title', 508 'text' => 'Evil:</textarea><script>alert("XSS")</script>', 509 'filter' => true, 510 'visual' => true, 511 ); 512 $this->assertFalse( $widget->is_legacy_instance( $instance ) ); 513 ob_start(); 514 $widget->form( $instance ); 515 $form = ob_get_clean(); 516 $this->assertNotContains( 'Evil:</textarea>', $form ); 517 $this->assertContains( 'Evil:</textarea>', $form ); 500 518 } 501 519
Note: See TracChangeset
for help on using the changeset viewer.