Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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/customize/partial.php

    r38858 r42343  
    4949    function test_construct_default_args() {
    5050        $partial_id = 'blogname';
    51         $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id );
     51        $partial    = new WP_Customize_Partial( $this->selective_refresh, $partial_id );
    5252        $this->assertEquals( $partial_id, $partial->id );
    5353        $this->assertEquals( $this->selective_refresh, $partial->component );
     
    8787    function test_construct_non_default_args() {
    8888
    89         $post_id = self::factory()->post->create( array(
    90             'post_title' => 'Hello World',
    91             'post_content' => 'Lorem Ipsum',
    92         ) );
     89        $post_id = self::factory()->post->create(
     90            array(
     91                'post_title'   => 'Hello World',
     92                'post_content' => 'Lorem Ipsum',
     93            )
     94        );
    9395
    9496        $partial_id = sprintf( 'post_content[%d]', $post_id );
    95         $args = array(
    96             'type' => 'post',
    97             'selector' => "article.post-$post_id .entry-content",
    98             'settings' => array( 'user[1]', "post[$post_id]" ),
    99             'primary_setting' => "post[$post_id]",
    100             'render_callback' => array( $this, 'render_post_content_partial' ),
     97        $args       = array(
     98            'type'                => 'post',
     99            'selector'            => "article.post-$post_id .entry-content",
     100            'settings'            => array( 'user[1]', "post[$post_id]" ),
     101            'primary_setting'     => "post[$post_id]",
     102            'render_callback'     => array( $this, 'render_post_content_partial' ),
    101103            'container_inclusive' => false,
    102             'fallback_refresh' => false,
    103         );
    104         $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args );
     104            'fallback_refresh'    => false,
     105        );
     106        $partial    = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args );
    105107        $this->assertEquals( $partial_id, $partial->id );
    106108        $this->assertEquals( $this->selective_refresh, $partial->component );
     
    114116        $this->assertContains( 'Lorem Ipsum', $partial->render() );
    115117
    116         $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, array(
    117             'settings' => 'blogdescription',
    118         ) );
     118        $partial = new WP_Customize_Partial(
     119            $this->selective_refresh, $partial_id, array(
     120                'settings' => 'blogdescription',
     121            )
     122        );
    119123        $this->assertEquals( array( 'blogdescription' ), $partial->settings );
    120124        $this->assertEquals( 'blogdescription', $partial->primary_setting );
     
    217221     */
    218222    function test_render_with_bad_callback_should_give_preference_to_return_value() {
    219         $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', array(
    220             'render_callback' => array( $this, 'render_echo_and_return' ),
    221         ) );
     223        $partial = new WP_Customize_Partial(
     224            $this->selective_refresh, 'foo', array(
     225                'render_callback' => array( $this, 'render_echo_and_return' ),
     226            )
     227        );
    222228        $this->setExpectedIncorrectUsage( 'render' );
    223229        $this->assertSame( 'bar', $partial->render() );
     
    230236     */
    231237    function test_render_echo_callback() {
    232         $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', array(
    233             'render_callback' => array( $this, 'render_echo' ),
    234         ) );
    235         $count_filter_customize_partial_render = $this->count_filter_customize_partial_render;
     238        $partial                                       = new WP_Customize_Partial(
     239            $this->selective_refresh, 'foo', array(
     240                'render_callback' => array( $this, 'render_echo' ),
     241            )
     242        );
     243        $count_filter_customize_partial_render         = $this->count_filter_customize_partial_render;
    236244        $count_filter_customize_partial_render_with_id = $this->count_filter_customize_partial_render_with_id;
    237245        add_filter( 'customize_partial_render', array( $this, 'filter_customize_partial_render' ), 10, 3 );
     
    249257     */
    250258    function test_render_return_callback() {
    251         $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', array(
    252             'render_callback' => array( $this, 'render_return' ),
    253         ) );
    254         $count_filter_customize_partial_render = $this->count_filter_customize_partial_render;
     259        $partial                                       = new WP_Customize_Partial(
     260            $this->selective_refresh, 'foo', array(
     261                'render_callback' => array( $this, 'render_return' ),
     262            )
     263        );
     264        $count_filter_customize_partial_render         = $this->count_filter_customize_partial_render;
    255265        $count_filter_customize_partial_render_with_id = $this->count_filter_customize_partial_render_with_id;
    256266        add_filter( 'customize_partial_render', array( $this, 'filter_customize_partial_render' ), 10, 3 );
     
    279289     */
    280290    function test_json() {
    281         $post_id = 123;
     291        $post_id    = 123;
    282292        $partial_id = sprintf( 'post_content[%d]', $post_id );
    283         $args = array(
    284             'type' => 'post',
    285             'selector' => "article.post-$post_id .entry-content",
    286             'settings' => array( 'user[1]', "post[$post_id]" ),
    287             'primary_setting' => "post[$post_id]",
    288             'render_callback' => array( $this, 'render_post_content_partial' ),
     293        $args       = array(
     294            'type'                => 'post',
     295            'selector'            => "article.post-$post_id .entry-content",
     296            'settings'            => array( 'user[1]', "post[$post_id]" ),
     297            'primary_setting'     => "post[$post_id]",
     298            'render_callback'     => array( $this, 'render_post_content_partial' ),
    289299            'container_inclusive' => false,
    290             'fallback_refresh' => false,
    291         );
    292         $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args );
     300            'fallback_refresh'    => false,
     301        );
     302        $partial    = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args );
    293303
    294304        $exported = $partial->json();
     
    309319        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    310320        do_action( 'customize_register', $this->wp_customize );
    311         $partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array(
    312             'settings' => array( 'blogname' ),
    313         ) );
     321        $partial = new WP_Customize_Partial(
     322            $this->selective_refresh, 'blogname', array(
     323                'settings' => array( 'blogname' ),
     324            )
     325        );
    314326        $this->assertTrue( $partial->check_capabilities() );
    315327
    316         $partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array(
    317             'settings' => array( 'blogname', 'non_existing' ),
    318         ) );
     328        $partial = new WP_Customize_Partial(
     329            $this->selective_refresh, 'blogname', array(
     330                'settings' => array( 'blogname', 'non_existing' ),
     331            )
     332        );
    319333        $this->assertFalse( $partial->check_capabilities() );
    320334
    321         $this->wp_customize->add_setting( 'top_secret_message', array(
    322             'capability' => 'top_secret_clearance',
    323         ) );
    324         $partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array(
    325             'settings' => array( 'blogname', 'top_secret_clearance' ),
    326         ) );
     335        $this->wp_customize->add_setting(
     336            'top_secret_message', array(
     337                'capability' => 'top_secret_clearance',
     338            )
     339        );
     340        $partial = new WP_Customize_Partial(
     341            $this->selective_refresh, 'blogname', array(
     342                'settings' => array( 'blogname', 'top_secret_clearance' ),
     343            )
     344        );
    327345        $this->assertFalse( $partial->check_capabilities() );
    328346
    329         $partial = new WP_Customize_Partial( $this->selective_refresh, 'no_setting', array(
    330             'settings' => array(),
    331         ) );
     347        $partial = new WP_Customize_Partial(
     348            $this->selective_refresh, 'no_setting', array(
     349                'settings' => array(),
     350            )
     351        );
    332352        $this->assertTrue( $partial->check_capabilities() );
    333353
    334         $partial = new WP_Customize_Partial( $this->selective_refresh, 'no_setting', array(
    335             'settings' => array(),
    336             'capability' => 'top_secret_clearance',
    337         ) );
     354        $partial = new WP_Customize_Partial(
     355            $this->selective_refresh, 'no_setting', array(
     356                'settings'   => array(),
     357                'capability' => 'top_secret_clearance',
     358            )
     359        );
    338360        $this->assertFalse( $partial->check_capabilities() );
    339361
    340         $partial = new WP_Customize_Partial( $this->selective_refresh, 'no_setting', array(
    341             'settings' => array(),
    342             'capability' => 'edit_theme_options',
    343         ) );
     362        $partial = new WP_Customize_Partial(
     363            $this->selective_refresh, 'no_setting', array(
     364                'settings'   => array(),
     365                'capability' => 'edit_theme_options',
     366            )
     367        );
    344368        $this->assertTrue( $partial->check_capabilities() );
    345369    }
Note: See TracChangeset for help on using the changeset viewer.