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/basic.php

    r40614 r42343  
    1919
    2020    function test_package_json() {
    21         $package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' );
    22         $package_json = json_decode( $package_json, true );
     21        $package_json    = file_get_contents( dirname( ABSPATH ) . '/package.json' );
     22        $package_json    = json_decode( $package_json, true );
    2323        list( $version ) = explode( '-', $GLOBALS['wp_version'] );
    2424        // package.json uses x.y.z, so fill cleaned $wp_version for .0 releases
     
    3838        $node = $package_json['engines']['node'];
    3939        $this->assertRegExp( '~^=?\d+\.\d+\.\d+$~', $node, "package.json's node version cannot be a range." );
    40     }
     40    }
    4141
    4242    // two tests for a lame bug in PHPUnit that broke the $GLOBALS reference
    4343    function test_globals() {
    4444        global $test_foo;
    45         $test_foo = array('foo', 'bar', 'baz');
     45        $test_foo = array( 'foo', 'bar', 'baz' );
    4646
    4747        function test_globals_foo() {
    48             unset($GLOBALS['test_foo'][1]);
     48            unset( $GLOBALS['test_foo'][1] );
    4949        }
    5050
    5151        test_globals_foo();
    5252
    53         $this->assertEquals($test_foo, array(0=>'foo', 2=>'baz'));
    54         $this->assertEquals($test_foo, $GLOBALS['test_foo']);
     53        $this->assertEquals(
     54            $test_foo, array(
     55                0 => 'foo',
     56                2 => 'baz',
     57            )
     58        );
     59        $this->assertEquals( $test_foo, $GLOBALS['test_foo'] );
    5560    }
    5661
    5762    function test_globals_bar() {
    5863        global $test_bar;
    59         $test_bar = array('a', 'b', 'c');
    60         $this->assertEquals($test_bar, $GLOBALS['test_bar']);
     64        $test_bar = array( 'a', 'b', 'c' );
     65        $this->assertEquals( $test_bar, $GLOBALS['test_bar'] );
    6166    }
    6267
     
    6469
    6570    function test_strip_ws() {
    66         $this->assertEquals('', strip_ws(''));
    67         $this->assertEquals('foo', strip_ws('foo'));
    68         $this->assertEquals('', strip_ws("\r\n\t  \n\r\t"));
     71        $this->assertEquals( '', strip_ws( '' ) );
     72        $this->assertEquals( 'foo', strip_ws( 'foo' ) );
     73        $this->assertEquals( '', strip_ws( "\r\n\t  \n\r\t" ) );
    6974
    7075        $in  = "asdf\n";
     
    8489        $expected .= "asdf\n";
    8590        $expected .= "foo bar\n";
    86         $expected .= "foo";
     91        $expected .= 'foo';
    8792
    88         $this->assertEquals($expected, strip_ws($in));
     93        $this->assertEquals( $expected, strip_ws( $in ) );
    8994
    9095    }
     
    104109        <ol id="authors"><form action="?import=wordpress&amp;step=2&amp;id=" method="post"><input type="hidden" name="_wpnonce" value="***" /><input type="hidden" name="_wp_http_referer" value="wp-test.php" /><li>Current author: <strong>Alex Shiels</strong><br />Create user  <input type="text" value="Alex Shiels" name="user[]" maxlength="30"> <br /> or map to existing<select name="userselect[0]">
    105110EOF;
    106         $this->assertEquals($expected, mask_input_value($in));
     111        $this->assertEquals( $expected, mask_input_value( $in ) );
    107112    }
    108113
     
    111116     */
    112117    function test_setting_nonexistent_arrays() {
    113         $page = 1;
     118        $page  = 1;
    114119        $field = 'settings';
    115120
    116         $empty_array[$page][$field] = 'foo';
     121        $empty_array[ $page ][ $field ] = 'foo';
    117122
    118123        // Assertion not strictly needed; we mainly want to show that a notice is not thrown.
    119         unset( $empty_array[$page]['bar']['baz'] );
     124        unset( $empty_array[ $page ]['bar']['baz'] );
    120125        $this->assertFalse( isset( $empty_array[ $page ]['bar']['baz'] ) );
    121126    }
     
    167172        $return = 'no match';
    168173        switch ( $var ) {
    169         default:
    170             break;
    171         case 1:
    172             $return = 'match';
    173             break;
     174            default:
     175                break;
     176            case 1:
     177                $return = 'match';
     178                break;
    174179        }
    175180
Note: See TracChangeset for help on using the changeset viewer.