Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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/media-gallery-widget.php

    r41590 r42343  
    2424        parent::clean_up_global_scope();
    2525        $wp_scripts = null;
    26         $wp_styles = null;
     26        $wp_styles  = null;
    2727    }
    2828
     
    6161            $test_image = '/tmp/' . $filename;
    6262            copy( DIR_TESTDATA . '/images/canola.jpg', $test_image );
    63             $attachment_id = self::factory()->attachment->create_object( array(
    64                 'file' => $test_image,
    65                 'post_parent' => 0,
    66                 'post_mime_type' => 'image/jpeg',
    67                 'post_title' => 'Canola',
    68             ) );
     63            $attachment_id = self::factory()->attachment->create_object(
     64                array(
     65                    'file'           => $test_image,
     66                    'post_parent'    => 0,
     67                    'post_mime_type' => 'image/jpeg',
     68                    'post_title'     => 'Canola',
     69                )
     70            );
    6971            wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $test_image ) );
    7072            $attachments[ $filename ] = $attachment_id;
    7173        }
    7274
    73         $instance = wp_list_pluck( $widget->get_instance_schema(), 'default' );
    74         $instance['size'] = 'thumbnail';
     75        $instance            = wp_list_pluck( $widget->get_instance_schema(), 'default' );
     76        $instance['size']    = 'thumbnail';
    7577        $instance['columns'] = 3;
    76         $instance['ids'] = array_values( $attachments );
     78        $instance['ids']     = array_values( $attachments );
    7779        ob_start();
    7880        $widget->render_media( $instance );
     
    110112     */
    111113    public function test_update() {
    112         $widget = new WP_Widget_Media_Gallery();
    113         $schema = $widget->get_instance_schema();
     114        $widget   = new WP_Widget_Media_Gallery();
     115        $schema   = $widget->get_instance_schema();
    114116        $instance = wp_list_pluck( $schema, 'default' );
    115117
    116118        // Field: title.
    117119        $instance['title'] = 'Hello <b>World</b> ';
    118         $instance = $widget->update( $instance, array() );
     120        $instance          = $widget->update( $instance, array() );
    119121        $this->assertEquals( 'Hello World', $instance['title'] );
    120122
    121123        // Field: ids.
    122124        $instance['ids'] = '1,2,3';
    123         $instance = $widget->update( $instance, array() );
     125        $instance        = $widget->update( $instance, array() );
    124126        $this->assertSame( array( 1, 2, 3 ), $instance['ids'] );
    125127
    126128        $instance['ids'] = array( 1, 2, '3' );
    127         $instance = $widget->update( $instance, array() );
     129        $instance        = $widget->update( $instance, array() );
    128130        $this->assertSame( array( 1, 2, 3 ), $instance['ids'] );
    129131
    130132        $instance['ids'] = array( 'too', 'bad' );
    131         $instance = $widget->update( $instance, array( 'ids' => array( 2, 3 ) ) );
     133        $instance        = $widget->update( $instance, array( 'ids' => array( 2, 3 ) ) );
    132134        $this->assertSame( array( 2, 3 ), $instance['ids'] );
    133135
    134136        // Field: columns.
    135137        $instance['columns'] = 4;
    136         $instance = $widget->update( $instance, array() );
     138        $instance            = $widget->update( $instance, array() );
    137139        $this->assertSame( 4, $instance['columns'] );
    138140
    139141        $instance['columns'] = '2';
    140         $instance = $widget->update( $instance, array() );
     142        $instance            = $widget->update( $instance, array() );
    141143        $this->assertSame( 2, $instance['columns'] );
    142144
    143145        $instance['columns'] = -1; // Under min of 1.
    144         $instance = $widget->update( $instance, array( 'columns' => 3 ) );
     146        $instance            = $widget->update( $instance, array( 'columns' => 3 ) );
    145147        $this->assertSame( 3, $instance['columns'] );
    146148
    147149        $instance['columns'] = 10; // Over max of 9.
    148         $instance = $widget->update( $instance, array( 'columns' => 3 ) );
     150        $instance            = $widget->update( $instance, array( 'columns' => 3 ) );
    149151        $this->assertSame( 3, $instance['columns'] );
    150152
    151153        // Field: size.
    152154        $instance['size'] = 'large';
    153         $instance = $widget->update( $instance, array() );
     155        $instance         = $widget->update( $instance, array() );
    154156        $this->assertSame( 'large', $instance['size'] );
    155157
    156158        $instance['size'] = 'bad';
    157         $instance = $widget->update( $instance, array( 'size' => 'thumbnail' ) );
     159        $instance         = $widget->update( $instance, array( 'size' => 'thumbnail' ) );
    158160        $this->assertSame( 'thumbnail', $instance['size'] );
    159161
    160162        // Field: link_type.
    161163        $instance['link_type'] = 'none';
    162         $instance = $widget->update( $instance, array() );
     164        $instance              = $widget->update( $instance, array() );
    163165        $this->assertSame( 'none', $instance['link_type'] );
    164166
    165167        $instance['link_type'] = 'unknown';
    166         $instance = $widget->update( $instance, array( 'link_type' => 'file' ) );
     168        $instance              = $widget->update( $instance, array( 'link_type' => 'file' ) );
    167169        $this->assertSame( 'file', $instance['link_type'] );
    168170
    169171        // Field: orderby_random.
    170172        $instance['orderby_random'] = '1';
    171         $instance = $widget->update( $instance, array() );
     173        $instance                   = $widget->update( $instance, array() );
    172174        $this->assertTrue( $instance['orderby_random'] );
    173175
    174176        $instance['orderby_random'] = true;
    175         $instance = $widget->update( $instance, array() );
     177        $instance                   = $widget->update( $instance, array() );
    176178        $this->assertTrue( $instance['orderby_random'] );
    177179
    178180        $instance['orderby_random'] = '';
    179         $instance = $widget->update( $instance, array() );
     181        $instance                   = $widget->update( $instance, array() );
    180182        $this->assertFalse( $instance['orderby_random'] );
    181183
    182184        $instance['orderby_random'] = false;
    183         $instance = $widget->update( $instance, array() );
     185        $instance                   = $widget->update( $instance, array() );
    184186        $this->assertFalse( $instance['orderby_random'] );
    185187    }
Note: See TracChangeset for help on using the changeset viewer.