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

    r41818 r42343  
    8282
    8383        $expected = array(
    84             "{$wpdb->prefix}dbdelta_create_test" => "Created table {$wpdb->prefix}dbdelta_create_test"
     84            "{$wpdb->prefix}dbdelta_create_test" => "Created table {$wpdb->prefix}dbdelta_create_test",
    8585        );
    8686
     
    8888
    8989        $this->assertEquals(
    90             "{$wpdb->prefix}dbdelta_create_test"
    91             , $wpdb->get_var(
     90            "{$wpdb->prefix}dbdelta_create_test", $wpdb->get_var(
    9291                $wpdb->prepare(
    93                     'SHOW TABLES LIKE %s'
    94                     , $wpdb->esc_like( "{$wpdb->prefix}dbdelta_create_test" )
     92                    'SHOW TABLES LIKE %s', $wpdb->esc_like( "{$wpdb->prefix}dbdelta_create_test" )
    9593                )
    9694            )
     
    145143            array(
    146144                "{$wpdb->prefix}dbdelta_test.id"
    147                     => "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint(20) to int(11)"
    148             )
    149             , $updates
     145                    => "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint(20) to int(11)",
     146            ), $updates
    150147        );
    151148    }
     
    174171            array(
    175172                "{$wpdb->prefix}dbdelta_test.extra_col"
    176                     => "Added column {$wpdb->prefix}dbdelta_test.extra_col"
    177             )
    178             , $updates
     173                    => "Added column {$wpdb->prefix}dbdelta_test.extra_col",
     174            ), $updates
    179175        );
    180176
    181177        $this->assertTableHasColumn( 'column_1', $wpdb->prefix . 'dbdelta_test' );
    182         $this->assertTableHasPrimaryKey( 'id' , $wpdb->prefix . 'dbdelta_test' );
     178        $this->assertTableHasPrimaryKey( 'id', $wpdb->prefix . 'dbdelta_test' );
    183179    }
    184180
     
    227223                KEY compound_key (id,column_1($this->max_index_length))
    228224            )
    229             "
    230             , false // Don't execute.
     225            ", false // Don't execute.
    231226        );
    232227
     
    234229            array(
    235230                "{$wpdb->prefix}dbdelta_test.extra_col"
    236                     => "Added column {$wpdb->prefix}dbdelta_test.extra_col"
    237             )
    238             , $updates
     231                    => "Added column {$wpdb->prefix}dbdelta_test.extra_col",
     232            ), $updates
    239233        );
    240234
     
    245239     * Test inserting into the database
    246240     */
    247     public function test_insert_into_table(){
     241    public function test_insert_into_table() {
    248242        global $wpdb;
    249243
     
    253247
    254248        $this->assertEquals(
    255             array( )
    256             , $insert
    257         );
    258 
    259         $this->assertTableRowHasValue( 'column_1', 'wcphilly2015',  $wpdb->prefix . 'dbdelta_test' );
     249            array(), $insert
     250        );
     251
     252        $this->assertTableRowHasValue( 'column_1', 'wcphilly2015', $wpdb->prefix . 'dbdelta_test' );
    260253
    261254    }
     
    263256    /**
    264257     * Test that FULLTEXT indexes are detected.
     258     *
    265259     * @ticket 14445
    266260     */
     
    301295
    302296        $expected = (object) array(
    303             $column => $value
     297            $column => $value,
    304298        );
    305299
     
    329323     * @param string $table  The database table name.
    330324     */
    331     protected function assertTableHasPrimaryKey( $column , $table ) {
     325    protected function assertTableHasPrimaryKey( $column, $table ) {
    332326        global $wpdb;
    333327
    334328        $table_indices = $wpdb->get_results( "SHOW INDEX FROM {$table}" );
    335329
    336         $this->assertCount( 1, wp_list_filter( $table_indices, array( 'Key_name' => 'PRIMARY' , 'Column_name' => $column ) , 'AND' ) );
     330        $this->assertCount(
     331            1, wp_list_filter(
     332                $table_indices, array(
     333                    'Key_name'    => 'PRIMARY',
     334                    'Column_name' => $column,
     335                ), 'AND'
     336            )
     337        );
    337338    }
    338339
     
    383384
    384385        if ( 191 != $index->Sub_part ) {
    385             $this->markTestSkipped( "This test requires the index to be truncated." );
     386            $this->markTestSkipped( 'This test requires the index to be truncated.' );
    386387        }
    387388
     
    407408                FULLTEXT KEY fulltext_key (column_1)
    408409            ) ENGINE=MyISAM
    409             ", false );
     410            ", false
     411        );
    410412
    411413        $this->assertSame( array(), $result );
     
    430432                FULLTEXT KEY fulltext_key (column_1)
    431433            ) ENGINE=MyISAM
    432             ", false );
     434            ", false
     435        );
    433436
    434437        $this->assertSame( array(), $result );
     
    453456                FULLTEXT KEY fulltext_key (column_1)
    454457            ) ENGINE=MyISAM
    455             ", false );
     458            ", false
     459        );
    456460
    457461        $this->assertSame(
    458462            array(
    459463                "{$wpdb->prefix}dbdelta_test.column_2"
    460                     => "Changed type of {$wpdb->prefix}dbdelta_test.column_2 from text to bigtext"
    461             ), $result );
     464                    => "Changed type of {$wpdb->prefix}dbdelta_test.column_2 from text to bigtext",
     465            ), $result
     466        );
    462467    }
    463468
     
    480485                FULLTEXT KEY fulltext_key (column_1)
    481486            ) ENGINE=MyISAM
    482             ", false );
     487            ", false
     488        );
    483489
    484490        $this->assertSame(
    485491            array(
    486492                "{$wpdb->prefix}dbdelta_test.column_3"
    487                     => "Changed type of {$wpdb->prefix}dbdelta_test.column_3 from blob to mediumblob"
    488             ), $result );
     493                    => "Changed type of {$wpdb->prefix}dbdelta_test.column_3 from blob to mediumblob",
     494            ), $result
     495        );
    489496    }
    490497
     
    553560        $updates = dbDelta( $schema, false );
    554561
    555         $this->assertSame( array(
    556             "{$wpdb->prefix}spatial_index_test.spatial_value2" => "Added column {$wpdb->prefix}spatial_index_test.spatial_value2",
    557             "Added index {$wpdb->prefix}spatial_index_test SPATIAL KEY `spatial_key2` (`spatial_value2`)"
    558             ), $updates );
     562        $this->assertSame(
     563            array(
     564                "{$wpdb->prefix}spatial_index_test.spatial_value2" => "Added column {$wpdb->prefix}spatial_index_test.spatial_value2",
     565                "Added index {$wpdb->prefix}spatial_index_test SPATIAL KEY `spatial_key2` (`spatial_value2`)",
     566            ), $updates
     567        );
    559568
    560569        $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}spatial_index_test" );
     
    580589        $updates = dbDelta( $schema );
    581590
    582         $table_indices = $wpdb->get_results( "SHOW INDEX FROM {$wpdb->prefix}dbdelta_test2" );
     591        $table_indices      = $wpdb->get_results( "SHOW INDEX FROM {$wpdb->prefix}dbdelta_test2" );
    583592        $compound_key_index = wp_list_filter( $table_indices, array( 'Key_name' => 'compound_key' ) );
    584593
     
    614623        $table_indices = $wpdb->get_results( "SHOW INDEX FROM {$wpdb->prefix}dbdelta_test" );
    615624
    616         $this->assertCount( 2, wp_list_filter( $table_indices, array( 'Key_name' => 'compound_key2' ) , 'AND' ) );
     625        $this->assertCount( 2, wp_list_filter( $table_indices, array( 'Key_name' => 'compound_key2' ), 'AND' ) );
    617626
    618627        $this->assertSame(
    619628            array(
    620629                "{$wpdb->prefix}dbdelta_test.references" => "Added column {$wpdb->prefix}dbdelta_test.references",
    621                 0 => "Added index {$wpdb->prefix}dbdelta_test KEY `compound_key2` (`id`,`references`($this->max_index_length))",
     630                0                                        => "Added index {$wpdb->prefix}dbdelta_test KEY `compound_key2` (`id`,`references`($this->max_index_length))",
    622631            ),
    623632            $updates
     
    844853                FULLTEXT KEY FULLtext_kEY (column_1)
    845854            ) ENGINE=MyISAM
    846             ", false );
     855            ", false
     856        );
    847857
    848858        $this->assertEmpty( $updates );
     
    867877                FULLTEXT KEY fulltext_key (column_1)
    868878            ) ENGINE=MyISAM
    869             ", false );
     879            ", false
     880        );
    870881
    871882        $this->assertEmpty( $updates );
     
    891902                FULLTEXT KEY fulltext_key (column_1)
    892903            ) ENGINE=MyISAM
    893             " );
    894 
    895         $this->assertSame( array(
    896             "Added index {$wpdb->prefix}dbdelta_test KEY `changing_key_length` (`column_1`(20))"
    897         ), $updates );
     904            "
     905        );
     906
     907        $this->assertSame(
     908            array(
     909                "Added index {$wpdb->prefix}dbdelta_test KEY `changing_key_length` (`column_1`(20))",
     910            ), $updates
     911        );
    898912
    899913        $updates = dbDelta(
     
    910924                FULLTEXT KEY fulltext_key (column_1)
    911925            ) ENGINE=MyISAM
    912             " );
     926            "
     927        );
    913928
    914929        $this->assertEmpty( $updates );
     
    927942                FULLTEXT KEY fulltext_key (column_1)
    928943            ) ENGINE=MyISAM
    929             " );
     944            "
     945        );
    930946
    931947        $this->assertEmpty( $updates );
     
    944960                FULLTEXT KEY fulltext_key (column_1)
    945961            ) ENGINE=MyISAM
    946             " );
     962            "
     963        );
    947964
    948965        $this->assertEmpty( $updates );
Note: See TracChangeset for help on using the changeset viewer.