mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 21:00:21 +00:00
Widgets: Rename "HTML Code" widget to "Custom HTML" widget.
Correspondingly renames files, ID base from `html_code` to `custom_html`, and the filter from `widget_html_code_content` to `widget_custom_html_content`. See #40907. git-svn-id: https://develop.svn.wordpress.org/trunk@40926 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+36
-24
@@ -1,32 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Unit tests covering WP_Widget_HTML_Code functionality.
|
||||
* Unit tests covering WP_Widget_Custom_HTML functionality.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test wp-includes/widgets/class-wp-widget-html-code.php
|
||||
* Test wp-includes/widgets/class-wp-widget-custom-html.php
|
||||
*
|
||||
* @group widgets
|
||||
*/
|
||||
class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
|
||||
class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Args passed to the widget_html_code_content filter.
|
||||
* Args passed to the widget_custom_html_content filter.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $widget_html_code_content_args;
|
||||
protected $widget_custom_html_content_args;
|
||||
|
||||
/**
|
||||
* Test constructor.
|
||||
*
|
||||
* @covers WP_Widget_Custom_HTML::__constructor
|
||||
*/
|
||||
function test_constructor() {
|
||||
$widget = new WP_Widget_Custom_HTML();
|
||||
$this->assertEquals( 'custom_html', $widget->id_base );
|
||||
$this->assertEquals( 'widget_custom_html', $widget->widget_options['classname'] );
|
||||
$this->assertTrue( $widget->widget_options['customize_selective_refresh'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test widget method.
|
||||
*
|
||||
* @covers WP_Widget_HTML_Code::widget
|
||||
* @covers WP_Widget_Custom_HTML::widget
|
||||
*/
|
||||
function test_widget() {
|
||||
$widget = new WP_Widget_HTML_Code();
|
||||
$widget = new WP_Widget_Custom_HTML();
|
||||
$content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed";
|
||||
|
||||
$args = array(
|
||||
@@ -40,22 +52,22 @@ class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
|
||||
'content' => $content,
|
||||
);
|
||||
|
||||
$this->assertEquals( 10, has_filter( 'widget_html_code_content', 'balanceTags' ) );
|
||||
$this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) );
|
||||
|
||||
update_option( 'use_balanceTags', 0 );
|
||||
add_filter( 'widget_html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 );
|
||||
add_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 );
|
||||
ob_start();
|
||||
$this->widget_html_code_content_args = null;
|
||||
$this->widget_custom_html_content_args = null;
|
||||
$widget->widget( $args, $instance );
|
||||
$output = ob_get_clean();
|
||||
$this->assertNotEmpty( $this->widget_html_code_content_args );
|
||||
$this->assertContains( '[filter:widget_html_code_content]', $output );
|
||||
$this->assertNotEmpty( $this->widget_custom_html_content_args );
|
||||
$this->assertContains( '[filter:widget_custom_html_content]', $output );
|
||||
$this->assertNotContains( '<p>', $output );
|
||||
$this->assertNotContains( '<br>', $output );
|
||||
$this->assertNotContains( '</u>', $output );
|
||||
$this->assertEquals( $instance, $this->widget_html_code_content_args[1] );
|
||||
$this->assertSame( $widget, $this->widget_html_code_content_args[2] );
|
||||
remove_filter( 'widget_html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 );
|
||||
$this->assertEquals( $instance, $this->widget_custom_html_content_args[1] );
|
||||
$this->assertSame( $widget, $this->widget_custom_html_content_args[2] );
|
||||
remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 );
|
||||
|
||||
update_option( 'use_balanceTags', 1 );
|
||||
ob_start();
|
||||
@@ -65,27 +77,27 @@ class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the content of the HTML Code widget.
|
||||
* Filters the content of the Custom HTML widget.
|
||||
*
|
||||
* @param string $widget_content The widget content.
|
||||
* @param array $instance Array of settings for the current widget.
|
||||
* @param WP_Widget_HTML_Code $widget Current HTML Code widget instance.
|
||||
* @param string $widget_content The widget content.
|
||||
* @param array $instance Array of settings for the current widget.
|
||||
* @param WP_Widget_Custom_HTML $widget Current Custom HTML widget instance.
|
||||
* @return string Widget content.
|
||||
*/
|
||||
function filter_widget_html_code_content( $widget_content, $instance, $widget ) {
|
||||
$this->widget_html_code_content_args = func_get_args();
|
||||
function filter_widget_custom_html_content( $widget_content, $instance, $widget ) {
|
||||
$this->widget_custom_html_content_args = func_get_args();
|
||||
|
||||
$widget_content .= '[filter:widget_html_code_content]';
|
||||
$widget_content .= '[filter:widget_custom_html_content]';
|
||||
return $widget_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update method.
|
||||
*
|
||||
* @covers WP_Widget_HTML_Code::update
|
||||
* @covers WP_Widget_Custom_HTML::update
|
||||
*/
|
||||
function test_update() {
|
||||
$widget = new WP_Widget_HTML_Code();
|
||||
$widget = new WP_Widget_Custom_HTML();
|
||||
$instance = array(
|
||||
'title' => "The\n<b>Title</b>",
|
||||
'content' => "The\n\n<b>Code</b>",
|
||||
Reference in New Issue
Block a user