WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (4 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r41957 r42343  
    3838        parent::clean_up_global_scope();
    3939        $wp_scripts = null;
    40         $wp_styles = null;
     40        $wp_styles  = null;
    4141    }
    4242
     
    7777     */
    7878    public function test_widget() {
    79         $widget = new WP_Widget_Custom_HTML();
     79        $widget  = new WP_Widget_Custom_HTML();
    8080        $content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed";
    8181
    82         $args = array(
     82        $args     = array(
    8383            'before_title'  => '<h2>',
    8484            'after_title'   => "</h2>\n",
     
    9292
    9393        // Convert Custom HTML widget instance into Text widget instance data.
    94         $text_widget_instance = array_merge( $instance, array(
    95             'text' => $instance['content'],
    96             'filter' => false,
    97             'visual' => false,
    98         ) );
     94        $text_widget_instance = array_merge(
     95            $instance, array(
     96                'text'   => $instance['content'],
     97                'filter' => false,
     98                'visual' => false,
     99            )
     100        );
    99101        unset( $text_widget_instance['content'] );
    100102
     
    104106        ob_start();
    105107        $this->widget_custom_html_content_args = null;
    106         $this->widget_text_args = null;
     108        $this->widget_text_args                = null;
    107109        $widget->widget( $args, $instance );
    108110        $output = ob_get_clean();
     
    139141    public function filter_widget_text( $text, $instance, $widget ) {
    140142        $this->widget_text_args = array( $text, $instance, $widget );
    141         $text .= '[filter:widget_text]';
     143        $text                  .= '[filter:widget_text]';
    142144        return $text;
    143145    }
     
    153155    public function filter_widget_custom_html_content( $widget_content, $instance, $widget ) {
    154156        $this->widget_custom_html_content_args = array( $widget_content, $instance, $widget );
    155         $widget_content .= '[filter:widget_custom_html_content]';
     157        $widget_content                       .= '[filter:widget_custom_html_content]';
    156158        return $widget_content;
    157159    }
     
    163165     */
    164166    public function test_update() {
    165         $widget = new WP_Widget_Custom_HTML();
     167        $widget   = new WP_Widget_Custom_HTML();
    166168        $instance = array(
    167169            'title'   => "The\n<b>Title</b>",
     
    169171        );
    170172
    171         wp_set_current_user( $this->factory()->user->create( array(
    172             'role' => 'administrator',
    173         ) ) );
     173        wp_set_current_user(
     174            $this->factory()->user->create(
     175                array(
     176                    'role' => 'administrator',
     177                )
     178            )
     179        );
    174180
    175181        // Should return valid instance.
     
    178184            'content' => $instance['content'],
    179185        );
    180         $result = $widget->update( $instance, array() );
     186        $result   = $widget->update( $instance, array() );
    181187        $this->assertEquals( $result, $expected );
    182188
     
    186192        $instance['content'] = '<script>alert( "Howdy!" );</script>';
    187193        $expected['content'] = $instance['content'];
    188         $result = $widget->update( $instance, array() );
     194        $result              = $widget->update( $instance, array() );
    189195        $this->assertEquals( $result, $expected );
    190196        remove_filter( 'map_meta_cap', array( $this, 'grant_unfiltered_html_cap' ) );
     
    194200        $instance['content'] = '<script>alert( "Howdy!" );</script>';
    195201        $expected['content'] = wp_kses_post( $instance['content'] );
    196         $result = $widget->update( $instance, array() );
     202        $result              = $widget->update( $instance, array() );
    197203        $this->assertEquals( $result, $expected );
    198204        remove_filter( 'map_meta_cap', array( $this, 'revoke_unfiltered_html_cap' ), 10 );
     
    208214    public function grant_unfiltered_html_cap( $caps, $cap ) {
    209215        if ( 'unfiltered_html' === $cap ) {
    210             $caps = array_diff( $caps, array( 'do_not_allow' ) );
     216            $caps   = array_diff( $caps, array( 'do_not_allow' ) );
    211217            $caps[] = 'unfiltered_html';
    212218        }
     
    223229    public function revoke_unfiltered_html_cap( $caps, $cap ) {
    224230        if ( 'unfiltered_html' === $cap ) {
    225             $caps = array_diff( $caps, array( 'unfiltered_html' ) );
     231            $caps   = array_diff( $caps, array( 'unfiltered_html' ) );
    226232            $caps[] = 'do_not_allow';
    227233        }
Note: See TracChangeset for help on using the changeset viewer.