Make WordPress Core


Ignore:
Timestamp:
06/23/2017 11:59:23 PM (8 years ago)
Author:
westonruter
Message:

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.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/custom-html-widget.php

    r40925 r40926  
    11<?php
    22/**
    3  * Unit tests covering WP_Widget_HTML_Code functionality.
     3 * Unit tests covering WP_Widget_Custom_HTML functionality.
    44 *
    55 * @package    WordPress
     
    88
    99/**
    10  * Test wp-includes/widgets/class-wp-widget-html-code.php
     10 * Test wp-includes/widgets/class-wp-widget-custom-html.php
    1111 *
    1212 * @group widgets
    1313 */
    14 class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
     14class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase {
    1515
    1616    /**
    17      * Args passed to the widget_html_code_content filter.
     17     * Args passed to the widget_custom_html_content filter.
    1818     *
    1919     * @var array
    2020     */
    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    }
    2234
    2335    /**
    2436     * Test widget method.
    2537     *
    26      * @covers WP_Widget_HTML_Code::widget
     38     * @covers WP_Widget_Custom_HTML::widget
    2739     */
    2840    function test_widget() {
    29         $widget = new WP_Widget_HTML_Code();
     41        $widget = new WP_Widget_Custom_HTML();
    3042        $content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed";
    3143
     
    4153        );
    4254
    43         $this->assertEquals( 10, has_filter( 'widget_html_code_content', 'balanceTags' ) );
     55        $this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) );
    4456
    4557        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 );
    4759        ob_start();
    48         $this->widget_html_code_content_args = null;
     60        $this->widget_custom_html_content_args = null;
    4961        $widget->widget( $args, $instance );
    5062        $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 );
    5365        $this->assertNotContains( '<p>', $output );
    5466        $this->assertNotContains( '<br>', $output );
    5567        $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 );
    5971
    6072        update_option( 'use_balanceTags', 1 );
     
    6678
    6779    /**
    68      * Filters the content of the HTML Code widget.
     80     * Filters the content of the Custom HTML widget.
    6981     *
    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 Code widget 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.
    7385     * @return string Widget content.
    7486     */
    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();
    7789
    78         $widget_content .= '[filter:widget_html_code_content]';
     90        $widget_content .= '[filter:widget_custom_html_content]';
    7991        return $widget_content;
    8092    }
     
    8395     * Test update method.
    8496     *
    85      * @covers WP_Widget_HTML_Code::update
     97     * @covers WP_Widget_Custom_HTML::update
    8698     */
    8799    function test_update() {
    88         $widget = new WP_Widget_HTML_Code();
     100        $widget = new WP_Widget_Custom_HTML();
    89101        $instance = array(
    90102            'title'   => "The\n<b>Title</b>",
Note: See TracChangeset for help on using the changeset viewer.