- Timestamp:
- 06/23/2017 11:59:23 PM (8 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets/custom-html-widget.php
r40925 r40926 1 1 <?php 2 2 /** 3 * Unit tests covering WP_Widget_ HTML_Codefunctionality.3 * Unit tests covering WP_Widget_Custom_HTML functionality. 4 4 * 5 5 * @package WordPress … … 8 8 9 9 /** 10 * Test wp-includes/widgets/class-wp-widget- html-code.php10 * Test wp-includes/widgets/class-wp-widget-custom-html.php 11 11 * 12 12 * @group widgets 13 13 */ 14 class Test_WP_Widget_ HTML_Codeextends WP_UnitTestCase {14 class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { 15 15 16 16 /** 17 * Args passed to the widget_ html_code_content filter.17 * Args passed to the widget_custom_html_content filter. 18 18 * 19 19 * @var array 20 20 */ 21 protected $widget_html_code_content_args; 21 protected $widget_custom_html_content_args; 22 23 /** 24 * Test constructor. 25 * 26 * @covers WP_Widget_Custom_HTML::__constructor 27 */ 28 function test_constructor() { 29 $widget = new WP_Widget_Custom_HTML(); 30 $this->assertEquals( 'custom_html', $widget->id_base ); 31 $this->assertEquals( 'widget_custom_html', $widget->widget_options['classname'] ); 32 $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); 33 } 22 34 23 35 /** 24 36 * Test widget method. 25 37 * 26 * @covers WP_Widget_ HTML_Code::widget38 * @covers WP_Widget_Custom_HTML::widget 27 39 */ 28 40 function test_widget() { 29 $widget = new WP_Widget_ HTML_Code();41 $widget = new WP_Widget_Custom_HTML(); 30 42 $content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed"; 31 43 … … 41 53 ); 42 54 43 $this->assertEquals( 10, has_filter( 'widget_ html_code_content', 'balanceTags' ) );55 $this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) ); 44 56 45 57 update_option( 'use_balanceTags', 0 ); 46 add_filter( 'widget_ html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 );58 add_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); 47 59 ob_start(); 48 $this->widget_ html_code_content_args = null;60 $this->widget_custom_html_content_args = null; 49 61 $widget->widget( $args, $instance ); 50 62 $output = ob_get_clean(); 51 $this->assertNotEmpty( $this->widget_ html_code_content_args );52 $this->assertContains( '[filter:widget_ html_code_content]', $output );63 $this->assertNotEmpty( $this->widget_custom_html_content_args ); 64 $this->assertContains( '[filter:widget_custom_html_content]', $output ); 53 65 $this->assertNotContains( '<p>', $output ); 54 66 $this->assertNotContains( '<br>', $output ); 55 67 $this->assertNotContains( '</u>', $output ); 56 $this->assertEquals( $instance, $this->widget_ html_code_content_args[1] );57 $this->assertSame( $widget, $this->widget_ html_code_content_args[2] );58 remove_filter( 'widget_ html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 );68 $this->assertEquals( $instance, $this->widget_custom_html_content_args[1] ); 69 $this->assertSame( $widget, $this->widget_custom_html_content_args[2] ); 70 remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); 59 71 60 72 update_option( 'use_balanceTags', 1 ); … … 66 78 67 79 /** 68 * Filters the content of the HTML Codewidget.80 * Filters the content of the Custom HTML widget. 69 81 * 70 * @param string $widget_content The widget content.71 * @param array $instance Array of settings for the current widget.72 * @param WP_Widget_ HTML_Code $widget Current HTML Codewidget instance.82 * @param string $widget_content The widget content. 83 * @param array $instance Array of settings for the current widget. 84 * @param WP_Widget_Custom_HTML $widget Current Custom HTML widget instance. 73 85 * @return string Widget content. 74 86 */ 75 function filter_widget_ html_code_content( $widget_content, $instance, $widget ) {76 $this->widget_ html_code_content_args = func_get_args();87 function filter_widget_custom_html_content( $widget_content, $instance, $widget ) { 88 $this->widget_custom_html_content_args = func_get_args(); 77 89 78 $widget_content .= '[filter:widget_ html_code_content]';90 $widget_content .= '[filter:widget_custom_html_content]'; 79 91 return $widget_content; 80 92 } … … 83 95 * Test update method. 84 96 * 85 * @covers WP_Widget_ HTML_Code::update97 * @covers WP_Widget_Custom_HTML::update 86 98 */ 87 99 function test_update() { 88 $widget = new WP_Widget_ HTML_Code();100 $widget = new WP_Widget_Custom_HTML(); 89 101 $instance = array( 90 102 'title' => "The\n<b>Title</b>",
Note: See TracChangeset
for help on using the changeset viewer.