- Timestamp:
- 07/18/2017 10:10:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets/custom-html-widget.php
r40926 r41086 20 20 */ 21 21 protected $widget_custom_html_content_args; 22 23 /** 24 * Args passed to the widget_text filter. 25 * 26 * @var array 27 */ 28 protected $widget_text_args; 22 29 23 30 /** … … 53 60 ); 54 61 55 $this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) );56 57 62 update_option( 'use_balanceTags', 0 ); 58 63 add_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); 64 add_filter( 'widget_text', array( $this, 'filter_widget_text' ), 10, 3 ); 59 65 ob_start(); 60 66 $this->widget_custom_html_content_args = null; 67 $this->widget_text_args = null; 61 68 $widget->widget( $args, $instance ); 62 69 $output = ob_get_clean(); 63 70 $this->assertNotEmpty( $this->widget_custom_html_content_args ); 64 $this->assertContains( '[filter:widget_custom_html_content]', $output ); 71 $this->assertNotEmpty( $this->widget_text_args ); 72 $this->assertContains( '[filter:widget_text][filter:widget_custom_html_content]', $output ); 65 73 $this->assertNotContains( '<p>', $output ); 66 74 $this->assertNotContains( '<br>', $output ); 67 75 $this->assertNotContains( '</u>', $output ); 76 $this->assertEquals( $instance, $this->widget_text_args[1] ); 68 77 $this->assertEquals( $instance, $this->widget_custom_html_content_args[1] ); 78 $this->assertSame( $widget, $this->widget_text_args[2] ); 69 79 $this->assertSame( $widget, $this->widget_custom_html_content_args[2] ); 70 80 remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); 81 remove_filter( 'widget_text', array( $this, 'filter_widget_text' ), 10 ); 71 82 72 83 update_option( 'use_balanceTags', 1 ); … … 78 89 79 90 /** 80 * Filters the content of the Custom HTML widget. 91 * Filters the content of the Custom HTML widget using the legacy widget_text filter. 92 * 93 * @param string $text The widget content. 94 * @param array $instance Array of settings for the current widget. 95 * @param WP_Widget_Custom_HTML $widget Current widget instance. 96 * @return string Widget content. 97 */ 98 function filter_widget_text( $text, $instance, $widget ) { 99 $this->widget_text_args = array( $text, $instance, $widget ); 100 $text .= '[filter:widget_text]'; 101 return $text; 102 } 103 104 /** 105 * Filters the content of the Custom HTML widget using the dedicated widget_custom_html_content filter. 81 106 * 82 107 * @param string $widget_content The widget content. … … 86 111 */ 87 112 function filter_widget_custom_html_content( $widget_content, $instance, $widget ) { 88 $this->widget_custom_html_content_args = func_get_args(); 89 113 $this->widget_custom_html_content_args = array( $widget_content, $instance, $widget ); 90 114 $widget_content .= '[filter:widget_custom_html_content]'; 91 115 return $widget_content;
Note: See TracChangeset
for help on using the changeset viewer.