Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 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/user/query.php

    r40982 r42343  
    1515
    1616        public static function wpSetUpBeforeClass( $factory ) {
    17                 self::$author_ids = $factory->user->create_many( 4, array(
    18                         'role' => 'author'
    19                 ) );
    20 
    21                 self::$sub_ids = $factory->user->create_many( 2, array(
    22                         'role' => 'subscriber',
    23                 ) );
    24 
    25                 self::$editor_ids = $factory->user->create_many( 3, array(
    26                         'role' => 'editor',
    27                 ) );
    28 
    29                 self::$contrib_id = $factory->user->create( array(
    30                         'role' => 'contributor',
    31                 ) );
    32 
    33                 self::$admin_ids = $factory->user->create_many( 2, array(
    34                         'role' => 'administrator',
    35                 ) );
     17                self::$author_ids = $factory->user->create_many(
     18                        4, array(
     19                                'role' => 'author',
     20                        )
     21                );
     22
     23                self::$sub_ids = $factory->user->create_many(
     24                        2, array(
     25                                'role' => 'subscriber',
     26                        )
     27                );
     28
     29                self::$editor_ids = $factory->user->create_many(
     30                        3, array(
     31                                'role' => 'editor',
     32                        )
     33                );
     34
     35                self::$contrib_id = $factory->user->create(
     36                        array(
     37                                'role' => 'contributor',
     38                        )
     39                );
     40
     41                self::$admin_ids = $factory->user->create_many(
     42                        2, array(
     43                                'role' => 'administrator',
     44                        )
     45                );
    3646        }
    3747
     
    5565
    5666        public function test_include_single() {
    57                 $q = new WP_User_Query( array(
    58                         'fields' => '',
    59                         'include' => self::$author_ids[0],
    60                 ) );
     67                $q   = new WP_User_Query(
     68                        array(
     69                                'fields'  => '',
     70                                'include' => self::$author_ids[0],
     71                        )
     72                );
    6173                $ids = $q->get_results();
    6274
     
    6577
    6678        public function test_include_comma_separated() {
    67                 $q = new WP_User_Query( array(
    68                         'fields' => '',
    69                         'include' => self::$author_ids[0] . ', ' . self::$author_ids[2],
    70                 ) );
     79                $q   = new WP_User_Query(
     80                        array(
     81                                'fields'  => '',
     82                                'include' => self::$author_ids[0] . ', ' . self::$author_ids[2],
     83                        )
     84                );
    7185                $ids = $q->get_results();
    7286
     
    7589
    7690        public function test_include_array() {
    77                 $q = new WP_User_Query( array(
    78                         'fields' => '',
    79                         'include' => array( self::$author_ids[0], self::$author_ids[2] ),
    80                 ) );
     91                $q   = new WP_User_Query(
     92                        array(
     93                                'fields'  => '',
     94                                'include' => array( self::$author_ids[0], self::$author_ids[2] ),
     95                        )
     96                );
    8197                $ids = $q->get_results();
    8298
     
    85101
    86102        public function test_include_array_bad_values() {
    87                 $q = new WP_User_Query( array(
    88                         'fields' => '',
    89                         'include' => array( self::$author_ids[0], 'foo', self::$author_ids[2] ),
    90                 ) );
     103                $q   = new WP_User_Query(
     104                        array(
     105                                'fields'  => '',
     106                                'include' => array( self::$author_ids[0], 'foo', self::$author_ids[2] ),
     107                        )
     108                );
    91109                $ids = $q->get_results();
    92110
     
    95113
    96114        public function test_exclude() {
    97                 $q = new WP_User_Query( array(
    98                         'fields' => '',
    99                         'exclude' => self::$author_ids[1],
    100                 ) );
     115                $q = new WP_User_Query(
     116                        array(
     117                                'fields'  => '',
     118                                'exclude' => self::$author_ids[1],
     119                        )
     120                );
    101121
    102122                $ids = $q->get_results();
     
    117137                }
    118138
    119                 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'fields' => 'all_with_meta' ) );
     139                $users = new WP_User_Query(
     140                        array(
     141                                'blog_id' => get_current_blog_id(),
     142                                'fields'  => 'all_with_meta',
     143                        )
     144                );
    120145                $users = $users->get_results();
    121146                $this->assertEquals( 13, count( $users ) );
     
    129154         */
    130155        public function test_get_total_is_int() {
    131                 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) );
     156                $users       = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) );
    132157                $total_users = $users->get_total();
    133158
     
    139164         */
    140165        public function test_orderby_should_convert_non_prefixed_keys( $short_key, $full_key ) {
    141                 $q = new WP_User_Query( array(
    142                         'orderby' => $short_key,
    143                 ) );
     166                $q = new WP_User_Query(
     167                        array(
     168                                'orderby' => $short_key,
     169                        )
     170                );
    144171
    145172                $this->assertContains( "ORDER BY $full_key", $q->query_orderby );
     
    161188                update_user_meta( self::$author_ids[2], 'last_name', 'Zorro' );
    162189
    163                 $q = new WP_User_Query( array(
    164                         'include' => self::$author_ids,
    165                         'meta_key' => 'last_name',
    166                         'orderby' => 'meta_value',
    167                         'fields' => 'ids'
    168                 ) );
     190                $q = new WP_User_Query(
     191                        array(
     192                                'include'  => self::$author_ids,
     193                                'meta_key' => 'last_name',
     194                                'orderby'  => 'meta_value',
     195                                'fields'   => 'ids',
     196                        )
     197                );
    169198
    170199                $expected = array( self::$author_ids[3], self::$author_ids[1], self::$author_ids[0], self::$author_ids[2] );
     
    181210                update_user_meta( self::$author_ids[2], 'user_age', '25' );
    182211
    183                 $q = new WP_User_Query( array(
    184                         'include' => self::$author_ids,
    185                         'meta_key' => 'user_age',
    186                         'orderby' => 'meta_value_num',
    187                         'fields' => 'ids'
    188                 ) );
     212                $q = new WP_User_Query(
     213                        array(
     214                                'include'  => self::$author_ids,
     215                                'meta_key' => 'user_age',
     216                                'orderby'  => 'meta_value_num',
     217                                'fields'   => 'ids',
     218                        )
     219                );
    189220
    190221                $expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] );
     
    201232                update_user_meta( self::$author_ids[2], 'foo', 'jjj' );
    202233
    203                 $q = new WP_User_Query( array(
    204                         'include' => self::$author_ids,
    205                         'meta_key' => 'foo',
    206                         'orderby' => 'foo',
    207                         'fields' => 'ids'
    208                 ) );
     234                $q = new WP_User_Query(
     235                        array(
     236                                'include'  => self::$author_ids,
     237                                'meta_key' => 'foo',
     238                                'orderby'  => 'foo',
     239                                'fields'   => 'ids',
     240                        )
     241                );
    209242
    210243                $expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] );
     
    221254                add_user_meta( self::$author_ids[2], 'foo', 'jjj' );
    222255
    223                 $q = new WP_User_Query( array(
    224                         'fields' => 'ids',
    225                         'meta_query' => array(
    226                                 'foo_key' => array(
    227                                         'key' => 'foo',
    228                                         'compare' => 'EXISTS',
     256                $q = new WP_User_Query(
     257                        array(
     258                                'fields'     => 'ids',
     259                                'meta_query' => array(
     260                                        'foo_key' => array(
     261                                                'key'     => 'foo',
     262                                                'compare' => 'EXISTS',
     263                                        ),
    229264                                ),
    230                         ),
    231                         'orderby' => 'foo_key',
    232                         'order' => 'DESC',
    233                 ) );
     265                                'orderby'    => 'foo_key',
     266                                'order'      => 'DESC',
     267                        )
     268                );
    234269
    235270                $this->assertEquals( array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] ), $q->results );
     
    240275         */
    241276        public function test_orderby_clause_key_as_secondary_sort() {
    242                 $u1 = self::factory()->user->create( array(
    243                         'user_registered' => '2015-01-28 03:00:00',
    244                 ) );
    245                 $u2 = self::factory()->user->create( array(
    246                         'user_registered' => '2015-01-28 05:00:00',
    247                 ) );
    248                 $u3 = self::factory()->user->create( array(
    249                         'user_registered' => '2015-01-28 03:00:00',
    250                 ) );
     277                $u1 = self::factory()->user->create(
     278                        array(
     279                                'user_registered' => '2015-01-28 03:00:00',
     280                        )
     281                );
     282                $u2 = self::factory()->user->create(
     283                        array(
     284                                'user_registered' => '2015-01-28 05:00:00',
     285                        )
     286                );
     287                $u3 = self::factory()->user->create(
     288                        array(
     289                                'user_registered' => '2015-01-28 03:00:00',
     290                        )
     291                );
    251292
    252293                add_user_meta( $u1, 'foo', 'jjj' );
     
    254295                add_user_meta( $u3, 'foo', 'aaa' );
    255296
    256                 $q = new WP_User_Query( array(
    257                         'fields' => 'ids',
    258                         'meta_query' => array(
    259                                 'foo_key' => array(
    260                                         'key' => 'foo',
    261                                         'compare' => 'EXISTS',
     297                $q = new WP_User_Query(
     298                        array(
     299                                'fields'     => 'ids',
     300                                'meta_query' => array(
     301                                        'foo_key' => array(
     302                                                'key'     => 'foo',
     303                                                'compare' => 'EXISTS',
     304                                        ),
    262305                                ),
    263                         ),
    264                         'orderby' => array(
    265                                 'comment_date' => 'asc',
    266                                 'foo_key' => 'asc',
    267                         ),
    268                 ) );
     306                                'orderby'    => array(
     307                                        'comment_date' => 'asc',
     308                                        'foo_key'      => 'asc',
     309                                ),
     310                        )
     311                );
    269312
    270313                $this->assertEquals( array( $u3, $u1, $u2 ), $q->results );
     
    282325                add_user_meta( self::$author_ids[2], 'bar', 'bbb' );
    283326
    284                 $q = new WP_User_Query( array(
    285                         'fields' => 'ids',
    286                         'meta_query' => array(
    287                                 'foo_key' => array(
    288                                         'key' => 'foo',
    289                                         'compare' => 'EXISTS',
     327                $q = new WP_User_Query(
     328                        array(
     329                                'fields'     => 'ids',
     330                                'meta_query' => array(
     331                                        'foo_key' => array(
     332                                                'key'     => 'foo',
     333                                                'compare' => 'EXISTS',
     334                                        ),
     335                                        'bar_key' => array(
     336                                                'key'     => 'bar',
     337                                                'compare' => 'EXISTS',
     338                                        ),
    290339                                ),
    291                                 'bar_key' => array(
    292                                         'key' => 'bar',
    293                                         'compare' => 'EXISTS',
     340                                'orderby'    => array(
     341                                        'foo_key' => 'asc',
     342                                        'bar_key' => 'desc',
    294343                                ),
    295                         ),
    296                         'orderby' => array(
    297                                 'foo_key' => 'asc',
    298                                 'bar_key' => 'desc',
    299                         ),
    300                 ) );
     344                        )
     345                );
    301346
    302347                $this->assertEquals( array( self::$author_ids[2], self::$author_ids[0], self::$author_ids[1] ), $q->results );
     
    307352         */
    308353        public function test_orderby_include_with_empty_include() {
    309                 $q = new WP_User_Query( array(
    310                         'orderby' => 'include',
    311                 ) );
     354                $q = new WP_User_Query(
     355                        array(
     356                                'orderby' => 'include',
     357                        )
     358                );
    312359
    313360                $this->assertContains( 'ORDER BY user_login', $q->query_orderby );
     
    320367                global $wpdb;
    321368
    322                 $q = new WP_User_Query( array(
    323                         'orderby' => 'include',
    324                         'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[3] ),
    325                         'fields' => '',
    326                 ) );
     369                $q = new WP_User_Query(
     370                        array(
     371                                'orderby' => 'include',
     372                                'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[3] ),
     373                                'fields'  => '',
     374                        )
     375                );
    327376
    328377                $expected_orderby = 'ORDER BY FIELD( ' . $wpdb->users . '.ID, ' . self::$author_ids[1] . ',' . self::$author_ids[0] . ',' . self::$author_ids[3] . ' )';
     
    339388                global $wpdb;
    340389
    341                 $q = new WP_User_Query( array(
    342                         'orderby' => 'include',
    343                         'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[1], self::$author_ids[3] ),
    344                         'fields' => '',
    345                 ) );
     390                $q = new WP_User_Query(
     391                        array(
     392                                'orderby' => 'include',
     393                                'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[1], self::$author_ids[3] ),
     394                                'fields'  => '',
     395                        )
     396                );
    346397
    347398                $expected_orderby = 'ORDER BY FIELD( ' . $wpdb->users . '.ID, ' . self::$author_ids[1] . ',' . self::$author_ids[0] . ',' . self::$author_ids[3] . ' )';
     
    356407         */
    357408        public function test_orderby_space_separated() {
    358                 $q = new WP_User_Query( array(
    359                         'orderby' => 'login nicename',
    360                         'order' => 'ASC',
    361                 ) );
    362 
    363                 $this->assertContains( "ORDER BY user_login ASC, user_nicename ASC", $q->query_orderby );
     409                $q = new WP_User_Query(
     410                        array(
     411                                'orderby' => 'login nicename',
     412                                'order'   => 'ASC',
     413                        )
     414                );
     415
     416                $this->assertContains( 'ORDER BY user_login ASC, user_nicename ASC', $q->query_orderby );
    364417        }
    365418
     
    368421         */
    369422        public function test_orderby_flat_array() {
    370                 $q = new WP_User_Query( array(
    371                         'orderby' => array( 'login', 'nicename' ),
    372                 ) );
    373 
    374                 $this->assertContains( "ORDER BY user_login ASC, user_nicename ASC", $q->query_orderby );
     423                $q = new WP_User_Query(
     424                        array(
     425                                'orderby' => array( 'login', 'nicename' ),
     426                        )
     427                );
     428
     429                $this->assertContains( 'ORDER BY user_login ASC, user_nicename ASC', $q->query_orderby );
    375430        }
    376431
     
    379434         */
    380435        public function test_orderby_array_contains_invalid_item() {
    381                 $q = new WP_User_Query( array(
    382                         'orderby' => array( 'login', 'foo', 'nicename' ),
    383                 ) );
    384 
    385                 $this->assertContains( "ORDER BY user_login ASC, user_nicename ASC", $q->query_orderby );
     436                $q = new WP_User_Query(
     437                        array(
     438                                'orderby' => array( 'login', 'foo', 'nicename' ),
     439                        )
     440                );
     441
     442                $this->assertContains( 'ORDER BY user_login ASC, user_nicename ASC', $q->query_orderby );
    386443        }
    387444
     
    390447         */
    391448        public function test_orderby_array_contains_all_invalid_items() {
    392                 $q = new WP_User_Query( array(
    393                         'orderby' => array( 'foo', 'bar', 'baz' ),
    394                 ) );
    395 
    396                 $this->assertContains( "ORDER BY user_login", $q->query_orderby );
     449                $q = new WP_User_Query(
     450                        array(
     451                                'orderby' => array( 'foo', 'bar', 'baz' ),
     452                        )
     453                );
     454
     455                $this->assertContains( 'ORDER BY user_login', $q->query_orderby );
    397456        }
    398457
     
    401460         */
    402461        public function test_orderby_array() {
    403                 $q = new WP_User_Query( array(
    404                         'orderby' => array(
    405                                 'login' => 'DESC',
    406                                 'nicename' => 'ASC',
    407                                 'email' => 'DESC',
    408                         ),
    409                 ) );
    410 
    411                 $this->assertContains( "ORDER BY user_login DESC, user_nicename ASC, user_email DESC", $q->query_orderby );
     462                $q = new WP_User_Query(
     463                        array(
     464                                'orderby' => array(
     465                                        'login'    => 'DESC',
     466                                        'nicename' => 'ASC',
     467                                        'email'    => 'DESC',
     468                                ),
     469                        )
     470                );
     471
     472                $this->assertContains( 'ORDER BY user_login DESC, user_nicename ASC, user_email DESC', $q->query_orderby );
    412473        }
    413474
     
    416477         */
    417478        public function test_orderby_array_should_discard_invalid_columns() {
    418                 $q = new WP_User_Query( array(
    419                         'orderby' => array(
    420                                 'login' => 'DESC',
    421                                 'foo' => 'ASC',
    422                                 'email' => 'ASC',
    423                         ),
    424                 ) );
    425 
    426                 $this->assertContains( "ORDER BY user_login DESC, user_email ASC", $q->query_orderby );
     479                $q = new WP_User_Query(
     480                        array(
     481                                'orderby' => array(
     482                                        'login' => 'DESC',
     483                                        'foo'   => 'ASC',
     484                                        'email' => 'ASC',
     485                                ),
     486                        )
     487                );
     488
     489                $this->assertContains( 'ORDER BY user_login DESC, user_email ASC', $q->query_orderby );
    427490        }
    428491
     
    436499                $this->assertEquals( 13, count( $users ) );
    437500
    438                 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'number' => 10 ) );
     501                $users = new WP_User_Query(
     502                        array(
     503                                'blog_id' => get_current_blog_id(),
     504                                'number'  => 10,
     505                        )
     506                );
    439507                $users = $users->get_results();
    440508                $this->assertEquals( 10, count( $users ) );
    441509
    442                 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'number' => 2 ) );
     510                $users = new WP_User_Query(
     511                        array(
     512                                'blog_id' => get_current_blog_id(),
     513                                'number'  => 2,
     514                        )
     515                );
    443516                $users = $users->get_results();
    444517                $this->assertEquals( 2, count( $users ) );
    445518
    446                 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'number' => -1 ) );
     519                $users = new WP_User_Query(
     520                        array(
     521                                'blog_id' => get_current_blog_id(),
     522                                'number'  => -1,
     523                        )
     524                );
    447525                $users = $users->get_results();
    448526                $this->assertEquals( 13, count( $users ) );
     
    491569
    492570        public function test_meta_vars_should_be_converted_to_meta_query() {
    493                 $q = new WP_User_Query( array(
    494                         'meta_key' => 'foo',
    495                         'meta_value' => '5',
    496                         'meta_compare' => '>',
    497                         'meta_type' => 'SIGNED',
    498                 ) );
     571                $q = new WP_User_Query(
     572                        array(
     573                                'meta_key'     => 'foo',
     574                                'meta_value'   => '5',
     575                                'meta_compare' => '>',
     576                                'meta_type'    => 'SIGNED',
     577                        )
     578                );
    499579
    500580                // Multisite adds a 'blog_id' clause, so we have to find the 'foo' clause.
     
    520600
    521601                // Users with foo = bar or baz restricted to the author role.
    522                 $query = new WP_User_Query( array(
    523                         'fields' => '',
    524                         'role' => 'author',
    525                         'meta_query' => array(
    526                                 'relation' => 'OR',
    527                                 array(
    528                                         'key' => 'foo',
    529                                         'value' => 'bar',
     602                $query = new WP_User_Query(
     603                        array(
     604                                'fields'     => '',
     605                                'role'       => 'author',
     606                                'meta_query' => array(
     607                                        'relation' => 'OR',
     608                                        array(
     609                                                'key'   => 'foo',
     610                                                'value' => 'bar',
     611                                        ),
     612                                        array(
     613                                                'key'   => 'foo',
     614                                                'value' => 'baz',
     615                                        ),
    530616                                ),
    531                                 array(
    532                                         'key' => 'foo',
    533                                         'value' => 'baz',
    534                                 ),
    535                         ),
    536                 ) );
     617                        )
     618                );
    537619
    538620                $this->assertEquals( array( self::$author_ids[0], self::$author_ids[1] ), $query->get_results() );
     
    540622
    541623        public function test_roles_and_caps_should_be_populated_for_default_value_of_blog_id() {
    542                 $query = new WP_User_Query( array(
    543                         'include' => self::$author_ids[0],
    544                 ) );
     624                $query = new WP_User_Query(
     625                        array(
     626                                'include' => self::$author_ids[0],
     627                        )
     628                );
    545629
    546630                $found = $query->get_results();
     
    556640         */
    557641        public function test_roles_and_caps_should_be_populated_for_explicit_value_of_blog_id_on_nonms() {
    558                 $query = new WP_User_Query( array(
    559                         'include' => self::$author_ids[0],
    560                         'blog_id' => get_current_blog_id(),
    561                 ) );
     642                $query = new WP_User_Query(
     643                        array(
     644                                'include' => self::$author_ids[0],
     645                                'blog_id' => get_current_blog_id(),
     646                        )
     647                );
    562648
    563649                $found = $query->get_results();
     
    573659         */
    574660        public function test_roles_and_caps_should_be_populated_for_explicit_value_of_current_blog_id_on_ms() {
    575                 $query = new WP_User_Query( array(
    576                         'include' => self::$author_ids[0],
    577                         'blog_id' => get_current_blog_id(),
    578                 ) );
     661                $query = new WP_User_Query(
     662                        array(
     663                                'include' => self::$author_ids[0],
     664                                'blog_id' => get_current_blog_id(),
     665                        )
     666                );
    579667
    580668                $found = $query->get_results();
     
    594682                add_user_to_blog( $b, self::$author_ids[0], 'author' );
    595683
    596                 $query = new WP_User_Query( array(
    597                         'include' => self::$author_ids[0],
    598                         'blog_id' => $b,
    599                         'fields' => 'all_with_meta',
    600                 ) );
     684                $query = new WP_User_Query(
     685                        array(
     686                                'include' => self::$author_ids[0],
     687                                'blog_id' => $b,
     688                                'fields'  => 'all_with_meta',
     689                        )
     690                );
    601691
    602692                $found = $query->get_results();
     
    616706                add_user_to_blog( $b, self::$author_ids[0], 'author' );
    617707
    618                 $query = new WP_User_Query( array(
    619                         'fields' => 'all',
    620                         'include' => self::$author_ids[0],
    621                         'blog_id' => $b,
    622                 ) );
     708                $query = new WP_User_Query(
     709                        array(
     710                                'fields'  => 'all',
     711                                'include' => self::$author_ids[0],
     712                                'blog_id' => $b,
     713                        )
     714                );
    623715
    624716                $found = $query->get_results();
     
    641733                add_user_to_blog( $b, self::$author_ids[2], 'editor' );
    642734
    643                 $q = new WP_User_Query( array(
    644                         'who' => 'authors',
    645                         'blog_id' => $b,
    646                 ) );
     735                $q = new WP_User_Query(
     736                        array(
     737                                'who'     => 'authors',
     738                                'blog_id' => $b,
     739                        )
     740                );
    647741
    648742                $found = wp_list_pluck( $q->get_results(), 'ID' );
     
    667761                add_user_meta( self::$author_ids[2], 'foo', 'baz' );
    668762
    669                 $q = new WP_User_Query( array(
    670                         'who' => 'authors',
    671                         'blog_id' => $b,
    672                         'meta_query' => array(
    673                                 array(
    674                                         'key' => 'foo',
    675                                         'value' => 'bar',
    676                                 )
    677                         ),
    678                 ) );
     763                $q = new WP_User_Query(
     764                        array(
     765                                'who'        => 'authors',
     766                                'blog_id'    => $b,
     767                                'meta_query' => array(
     768                                        array(
     769                                                'key'   => 'foo',
     770                                                'value' => 'bar',
     771                                        ),
     772                                ),
     773                        )
     774                );
    679775
    680776                $found = wp_list_pluck( $q->get_results(), 'ID' );
     
    699795                add_user_meta( self::$author_ids[2], 'foo', 'baz' );
    700796
    701                 $q = new WP_User_Query( array(
    702                         'who' => 'authors',
    703                         'blog_id' => $b,
    704                         'meta_key' => 'foo',
    705                         'meta_value' => 'bar',
    706                 ) );
     797                $q = new WP_User_Query(
     798                        array(
     799                                'who'        => 'authors',
     800                                'blog_id'    => $b,
     801                                'meta_key'   => 'foo',
     802                                'meta_value' => 'bar',
     803                        )
     804                );
    707805
    708806                $found = wp_list_pluck( $q->get_results(), 'ID' );
     
    720818                register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    721819
    722                 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
    723                 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
    724 
    725                 $q = new WP_User_Query( array(
    726                         'has_published_posts' => true,
    727                 ) );
    728 
    729                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     820                self::factory()->post->create(
     821                        array(
     822                                'post_author' => self::$author_ids[0],
     823                                'post_status' => 'publish',
     824                                'post_type'   => 'wptests_pt_public',
     825                        )
     826                );
     827                self::factory()->post->create(
     828                        array(
     829                                'post_author' => self::$author_ids[1],
     830                                'post_status' => 'publish',
     831                                'post_type'   => 'wptests_pt_private',
     832                        )
     833                );
     834
     835                $q = new WP_User_Query(
     836                        array(
     837                                'has_published_posts' => true,
     838                        )
     839                );
     840
     841                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    730842                $expected = array( self::$author_ids[0] );
    731843
     
    740852                register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    741853
    742                 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
    743                 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
    744                 self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
    745 
    746                 $q = new WP_User_Query( array(
    747                         'has_published_posts' => array( 'wptests_pt_private', 'post' ),
    748                 ) );
    749 
    750                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     854                self::factory()->post->create(
     855                        array(
     856                                'post_author' => self::$author_ids[0],
     857                                'post_status' => 'publish',
     858                                'post_type'   => 'wptests_pt_public',
     859                        )
     860                );
     861                self::factory()->post->create(
     862                        array(
     863                                'post_author' => self::$author_ids[1],
     864                                'post_status' => 'publish',
     865                                'post_type'   => 'wptests_pt_private',
     866                        )
     867                );
     868                self::factory()->post->create(
     869                        array(
     870                                'post_author' => self::$author_ids[2],
     871                                'post_status' => 'publish',
     872                                'post_type'   => 'post',
     873                        )
     874                );
     875
     876                $q = new WP_User_Query(
     877                        array(
     878                                'has_published_posts' => array( 'wptests_pt_private', 'post' ),
     879                        )
     880                );
     881
     882                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    751883                $expected = array( self::$author_ids[1], self::$author_ids[2] );
    752884
     
    761893                register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    762894
    763                 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) );
    764                 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) );
    765                 self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
    766 
    767                 $q = new WP_User_Query( array(
    768                         'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ),
    769                 ) );
    770 
    771                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     895                self::factory()->post->create(
     896                        array(
     897                                'post_author' => self::$author_ids[0],
     898                                'post_status' => 'draft',
     899                                'post_type'   => 'wptests_pt_public',
     900                        )
     901                );
     902                self::factory()->post->create(
     903                        array(
     904                                'post_author' => self::$author_ids[1],
     905                                'post_status' => 'inherit',
     906                                'post_type'   => 'wptests_pt_private',
     907                        )
     908                );
     909                self::factory()->post->create(
     910                        array(
     911                                'post_author' => self::$author_ids[2],
     912                                'post_status' => 'publish',
     913                                'post_type'   => 'post',
     914                        )
     915                );
     916
     917                $q = new WP_User_Query(
     918                        array(
     919                                'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ),
     920                        )
     921                );
     922
     923                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    772924                $expected = array( self::$author_ids[2] );
    773925
     
    788940
    789941                switch_to_blog( $blogs[0] );
    790                 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) );
     942                self::factory()->post->create(
     943                        array(
     944                                'post_author' => self::$author_ids[0],
     945                                'post_status' => 'publish',
     946                                'post_type'   => 'post',
     947                        )
     948                );
    791949                restore_current_blog();
    792950
    793951                switch_to_blog( $blogs[1] );
    794                 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) );
     952                self::factory()->post->create(
     953                        array(
     954                                'post_author' => self::$author_ids[1],
     955                                'post_status' => 'publish',
     956                                'post_type'   => 'post',
     957                        )
     958                );
    795959                restore_current_blog();
    796960
    797                 $q = new WP_User_Query( array(
    798                         'has_published_posts' => array( 'post' ),
    799                         'blog_id' => $blogs[1],
    800                 ) );
    801 
    802                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     961                $q = new WP_User_Query(
     962                        array(
     963                                'has_published_posts' => array( 'post' ),
     964                                'blog_id'             => $blogs[1],
     965                        )
     966                );
     967
     968                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    803969                $expected = array( self::$author_ids[1] );
    804970
     
    814980                add_user_meta( self::$author_ids[0], 'foo2', 'bar2' );
    815981
    816                 $q = new WP_User_Query( array(
    817                         'meta_query' => array(
    818                                 'relation' => 'OR',
    819                                 array(
    820                                         'key' => 'foo',
    821                                         'value' => 'bar',
     982                $q = new WP_User_Query(
     983                        array(
     984                                'meta_query' => array(
     985                                        'relation' => 'OR',
     986                                        array(
     987                                                'key'   => 'foo',
     988                                                'value' => 'bar',
     989                                        ),
     990                                        array(
     991                                                'key'   => 'foo2',
     992                                                'value' => 'bar2',
     993                                        ),
    822994                                ),
    823                                 array(
    824                                         'key' => 'foo2',
    825                                         'value' => 'bar2',
    826                                 ),
    827                         ),
    828                 ) );
    829 
    830                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     995                        )
     996                );
     997
     998                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    831999                $expected = array( self::$author_ids[0], self::$author_ids[1] );
    8321000
     
    8431011                add_user_meta( self::$author_ids[1], 'foo3', 'bar3' );
    8441012
    845                 $q = new WP_User_Query( array(
    846                         'meta_query' => array(
    847                                 'relation' => 'AND',
    848                                 array(
    849                                         'key' => 'foo',
    850                                         'value' => 'bar',
    851                                 ),
    852                                 array(
    853                                         'relation' => 'OR',
     1013                $q = new WP_User_Query(
     1014                        array(
     1015                                'meta_query' => array(
     1016                                        'relation' => 'AND',
    8541017                                        array(
    855                                                 'key' => 'foo',
     1018                                                'key'   => 'foo',
    8561019                                                'value' => 'bar',
    8571020                                        ),
    8581021                                        array(
    859                                                 'key' => 'foo2',
    860                                                 'value' => 'bar2',
     1022                                                'relation' => 'OR',
     1023                                                array(
     1024                                                        'key'   => 'foo',
     1025                                                        'value' => 'bar',
     1026                                                ),
     1027                                                array(
     1028                                                        'key'   => 'foo2',
     1029                                                        'value' => 'bar2',
     1030                                                ),
    8611031                                        ),
    8621032                                ),
    863                         ),
    864                 ) );
    865 
    866                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     1033                        )
     1034                );
     1035
     1036                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    8671037                $expected = array( self::$author_ids[0], self::$author_ids[1] );
    8681038
     
    8741044         */
    8751045        public function test_nicename_returns_user_with_nicename() {
    876                 wp_update_user( array(
    877                         'ID' => self::$author_ids[0],
    878                         'user_nicename' => 'peter'
    879                 ) );
    880 
    881                 $q = new WP_User_Query( array (
    882                         'nicename' => 'peter'
    883                 ) );
    884 
    885                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     1046                wp_update_user(
     1047                        array(
     1048                                'ID'            => self::$author_ids[0],
     1049                                'user_nicename' => 'peter',
     1050                        )
     1051                );
     1052
     1053                $q = new WP_User_Query(
     1054                        array(
     1055                                'nicename' => 'peter',
     1056                        )
     1057                );
     1058
     1059                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    8861060                $expected = array( self::$author_ids[0] );
    8871061
    888                 $this->assertContains( "AND user_nicename = 'peter'", $q->query_where);
    889                 $this->assertEqualSets( $expected, $found);
     1062                $this->assertContains( "AND user_nicename = 'peter'", $q->query_where );
     1063                $this->assertEqualSets( $expected, $found );
    8901064        }
    8911065
     
    8941068         */
    8951069        public function test_nicename__in_returns_users_with_included_nicenames() {
    896                 wp_update_user( array(
    897                         'ID' => self::$author_ids[0],
    898                         'user_nicename' => 'peter'
    899                 ) );
    900 
    901                 wp_update_user( array(
    902                         'ID' => self::$author_ids[1],
    903                         'user_nicename' => 'paul'
    904                 ) );
    905 
    906                 wp_update_user( array(
    907                         'ID' => self::$author_ids[2],
    908                         'user_nicename' => 'mary'
    909                 ) );
    910 
    911                 $q = new WP_User_Query( array (
    912                         'nicename__in' => array( 'peter', 'paul', 'mary' )
    913                 ) );
    914 
    915                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     1070                wp_update_user(
     1071                        array(
     1072                                'ID'            => self::$author_ids[0],
     1073                                'user_nicename' => 'peter',
     1074                        )
     1075                );
     1076
     1077                wp_update_user(
     1078                        array(
     1079                                'ID'            => self::$author_ids[1],
     1080                                'user_nicename' => 'paul',
     1081                        )
     1082                );
     1083
     1084                wp_update_user(
     1085                        array(
     1086                                'ID'            => self::$author_ids[2],
     1087                                'user_nicename' => 'mary',
     1088                        )
     1089                );
     1090
     1091                $q = new WP_User_Query(
     1092                        array(
     1093                                'nicename__in' => array( 'peter', 'paul', 'mary' ),
     1094                        )
     1095                );
     1096
     1097                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    9161098                $expected = array( self::$author_ids[0], self::$author_ids[1], self::$author_ids[2] );
    9171099
    918                 $this->assertContains( "AND user_nicename IN ( 'peter','paul','mary' )", $q->query_where);
     1100                $this->assertContains( "AND user_nicename IN ( 'peter','paul','mary' )", $q->query_where );
    9191101                $this->assertEqualSets( $expected, $found );
    9201102        }
     
    9241106         */
    9251107        public function test_nicename__not_in_returns_users_without_included_nicenames() {
    926                 wp_update_user( array(
    927                         'ID' => self::$author_ids[0],
    928                         'user_nicename' => 'peter'
    929                 ) );
    930 
    931                 wp_update_user( array(
    932                         'ID' => self::$author_ids[1],
    933                         'user_nicename' => 'paul'
    934                 ) );
    935 
    936                 wp_update_user( array(
    937                         'ID' => self::$author_ids[2],
    938                         'user_nicename' => 'mary'
    939                 ) );
    940 
    941                 $q = new WP_User_Query( array (
    942                         'nicename__not_in' => array( 'peter', 'paul', 'mary' )
    943                 ) );
    944 
    945                 $foundCount = count($q->get_results());
     1108                wp_update_user(
     1109                        array(
     1110                                'ID'            => self::$author_ids[0],
     1111                                'user_nicename' => 'peter',
     1112                        )
     1113                );
     1114
     1115                wp_update_user(
     1116                        array(
     1117                                'ID'            => self::$author_ids[1],
     1118                                'user_nicename' => 'paul',
     1119                        )
     1120                );
     1121
     1122                wp_update_user(
     1123                        array(
     1124                                'ID'            => self::$author_ids[2],
     1125                                'user_nicename' => 'mary',
     1126                        )
     1127                );
     1128
     1129                $q = new WP_User_Query(
     1130                        array(
     1131                                'nicename__not_in' => array( 'peter', 'paul', 'mary' ),
     1132                        )
     1133                );
     1134
     1135                $foundCount    = count( $q->get_results() );
    9461136                $expectedCount = 10; // 13 total users minus 3 from query
    9471137
    948                 $this->assertContains( "AND user_nicename NOT IN ( 'peter','paul','mary' )", $q->query_where);
     1138                $this->assertContains( "AND user_nicename NOT IN ( 'peter','paul','mary' )", $q->query_where );
    9491139                $this->assertEquals( $expectedCount, $foundCount );
    9501140        }
     
    9541144         */
    9551145        public function test_orderby_nicename__in() {
    956                 wp_update_user( array(
    957                         'ID' => self::$author_ids[0],
    958                         'user_nicename' => 'peter'
    959                 ) );
    960 
    961                 wp_update_user( array(
    962                         'ID' => self::$author_ids[1],
    963                         'user_nicename' => 'paul'
    964                 ) );
    965 
    966                 wp_update_user( array(
    967                         'ID' => self::$author_ids[2],
    968                         'user_nicename' => 'mary'
    969                 ) );
    970 
    971                 $q = new WP_User_Query( array (
    972                         'nicename__in' => array( 'mary', 'peter', 'paul' ),
    973                         'orderby' => 'nicename__in'
    974                 ) );
    975 
    976                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     1146                wp_update_user(
     1147                        array(
     1148                                'ID'            => self::$author_ids[0],
     1149                                'user_nicename' => 'peter',
     1150                        )
     1151                );
     1152
     1153                wp_update_user(
     1154                        array(
     1155                                'ID'            => self::$author_ids[1],
     1156                                'user_nicename' => 'paul',
     1157                        )
     1158                );
     1159
     1160                wp_update_user(
     1161                        array(
     1162                                'ID'            => self::$author_ids[2],
     1163                                'user_nicename' => 'mary',
     1164                        )
     1165                );
     1166
     1167                $q = new WP_User_Query(
     1168                        array(
     1169                                'nicename__in' => array( 'mary', 'peter', 'paul' ),
     1170                                'orderby'      => 'nicename__in',
     1171                        )
     1172                );
     1173
     1174                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    9771175                $expected = array( self::$author_ids[2], self::$author_ids[0], self::$author_ids[1] );
    9781176
    979                 $this->assertContains( "FIELD( user_nicename, 'mary','peter','paul' )", $q->query_orderby);
     1177                $this->assertContains( "FIELD( user_nicename, 'mary','peter','paul' )", $q->query_orderby );
    9801178                $this->assertSame( $expected, $found );
    9811179        }
     
    9881186                $user_login = get_userdata( self::$author_ids[0] )->user_login;
    9891187
    990                 $q = new WP_User_Query( array (
    991                         'login' => $user_login
    992                 ) );
    993 
    994                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     1188                $q = new WP_User_Query(
     1189                        array(
     1190                                'login' => $user_login,
     1191                        )
     1192                );
     1193
     1194                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    9951195                $expected = array( self::$author_ids[0] );
    9961196
    997                 $this->assertContains( "AND user_login = '$user_login'", $q->query_where);
    998                 $this->assertEqualSets( $expected, $found);
     1197                $this->assertContains( "AND user_login = '$user_login'", $q->query_where );
     1198                $this->assertEqualSets( $expected, $found );
    9991199        }
    10001200
     
    10071207                $user_login3 = get_userdata( self::$author_ids[2] )->user_login;
    10081208
    1009                 $q = new WP_User_Query( array (
    1010                         'login__in' => array( $user_login1, $user_login2, $user_login3 )
    1011                 ) );
    1012 
    1013                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     1209                $q = new WP_User_Query(
     1210                        array(
     1211                                'login__in' => array( $user_login1, $user_login2, $user_login3 ),
     1212                        )
     1213                );
     1214
     1215                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    10141216                $expected = array( self::$author_ids[0], self::$author_ids[1], self::$author_ids[2] );
    10151217
    1016                 $this->assertContains( "AND user_login IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where);
     1218                $this->assertContains( "AND user_login IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where );
    10171219                $this->assertEqualSets( $expected, $found );
    10181220        }
     
    10261228                $user_login3 = get_userdata( self::$author_ids[2] )->user_login;
    10271229
    1028                 $q = new WP_User_Query( array (
    1029                         'login__not_in' => array( $user_login1, $user_login2, $user_login3 )
    1030                 ) );
    1031 
    1032                 $foundCount = count($q->get_results());
     1230                $q = new WP_User_Query(
     1231                        array(
     1232                                'login__not_in' => array( $user_login1, $user_login2, $user_login3 ),
     1233                        )
     1234                );
     1235
     1236                $foundCount    = count( $q->get_results() );
    10331237                $expectedCount = 10; // 13 total users minus 3 from query
    10341238
    1035                 $this->assertContains( "AND user_login NOT IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where);
     1239                $this->assertContains( "AND user_login NOT IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where );
    10361240                $this->assertEquals( $expectedCount, $foundCount );
    10371241        }
     
    10451249                $user_login3 = get_userdata( self::$author_ids[2] )->user_login;
    10461250
    1047                 $q = new WP_User_Query( array (
    1048                         'login__in' => array( $user_login2, $user_login3, $user_login1 ),
    1049                         'orderby' => 'login__in'
    1050                 ) );
    1051 
    1052                 $found = wp_list_pluck( $q->get_results(), 'ID' );
     1251                $q = new WP_User_Query(
     1252                        array(
     1253                                'login__in' => array( $user_login2, $user_login3, $user_login1 ),
     1254                                'orderby'   => 'login__in',
     1255                        )
     1256                );
     1257
     1258                $found    = wp_list_pluck( $q->get_results(), 'ID' );
    10531259                $expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] );
    10541260
    1055                 $this->assertContains( "FIELD( user_login, '$user_login2','$user_login3','$user_login1' )", $q->query_orderby);
     1261                $this->assertContains( "FIELD( user_login, '$user_login2','$user_login3','$user_login1' )", $q->query_orderby );
    10561262                $this->assertSame( $expected, $found );
    10571263        }
     
    10611267         */
    10621268        public function test_paged() {
    1063                 $q = new WP_User_Query( array(
    1064                         'number' => 2,
    1065                         'paged' => 2,
    1066                         'orderby' => 'ID',
    1067                         'order' => 'DESC', // Avoid funkiness with user 1.
    1068                         'fields' => 'ids',
    1069                 ) );
     1269                $q = new WP_User_Query(
     1270                        array(
     1271                                'number'  => 2,
     1272                                'paged'   => 2,
     1273                                'orderby' => 'ID',
     1274                                'order'   => 'DESC', // Avoid funkiness with user 1.
     1275                                'fields'  => 'ids',
     1276                        )
     1277                );
    10701278
    10711279                $this->assertEquals( array( self::$contrib_id, self::$editor_ids[2] ), $q->results );
     
    11171325         */
    11181326        public function test_get_single_role_by_string() {
    1119                 $users = get_users( array(
    1120                         'role' => 'subscriber',
    1121                 ) );
     1327                $users = get_users(
     1328                        array(
     1329                                'role' => 'subscriber',
     1330                        )
     1331                );
    11221332
    11231333                $this->assertEquals( 2, count( $users ) );
     
    11281338         */
    11291339        public function test_get_single_role_by_string_which_is_similar() {
    1130                 $another_editor = self::factory()->user->create( array(
    1131                         'user_email' => 'another_editor@another_editor.com',
    1132                         'user_login' => 'another_editor',
    1133                         'role' => 'another-editor',
    1134                 ) );
    1135 
    1136                 $users = get_users( array(
    1137                         'role' => 'editor',
    1138                         'fields' => 'ids',
    1139                 ) );
     1340                $another_editor = self::factory()->user->create(
     1341                        array(
     1342                                'user_email' => 'another_editor@another_editor.com',
     1343                                'user_login' => 'another_editor',
     1344                                'role'       => 'another-editor',
     1345                        )
     1346                );
     1347
     1348                $users = get_users(
     1349                        array(
     1350                                'role'   => 'editor',
     1351                                'fields' => 'ids',
     1352                        )
     1353                );
    11401354
    11411355                $this->assertEqualSets( self::$editor_ids, $users );
     
    11471361         */
    11481362        public function test_get_single_role_by_array() {
    1149                 $users = get_users( array(
    1150                         'role' => array( 'subscriber' ),
    1151                 ) );
     1363                $users = get_users(
     1364                        array(
     1365                                'role' => array( 'subscriber' ),
     1366                        )
     1367                );
    11521368
    11531369                $this->assertEquals( 2, count( $users ) );
     
    11961412         */
    11971413        public function test_get_multiple_roles_by_comma_separated_list() {
    1198                 $users = get_users( array(
    1199                         'role' => 'subscriber, editor',
    1200                 ) );
     1414                $users = get_users(
     1415                        array(
     1416                                'role' => 'subscriber, editor',
     1417                        )
     1418                );
    12011419
    12021420                $this->assertEmpty( $users );
     
    12071425                }
    12081426
    1209                 $users = get_users( array(
    1210                         'role' => 'subscriber, editor',
    1211                 ) );
     1427                $users = get_users(
     1428                        array(
     1429                                'role' => 'subscriber, editor',
     1430                        )
     1431                );
    12121432
    12131433                $this->assertEquals( 2, count( $users ) );
     
    12351455
    12361456                // Fetch users
    1237                 $users = get_users( array(
    1238                         'role__in'   => array( 'administrator', 'editor', 'subscriber' ),
    1239                         'meta_query' => array(
    1240                                 'relation' => 'AND',
    1241                                 array(
    1242                                         'key'     => 'mk1',
    1243                                         'value'   => '1',
    1244                                         'compare' => "=",
    1245                                         'type'    => 'numeric',
     1457                $users = get_users(
     1458                        array(
     1459                                'role__in'   => array( 'administrator', 'editor', 'subscriber' ),
     1460                                'meta_query' => array(
     1461                                        'relation' => 'AND',
     1462                                        array(
     1463                                                'key'     => 'mk1',
     1464                                                'value'   => '1',
     1465                                                'compare' => '=',
     1466                                                'type'    => 'numeric',
     1467                                        ),
     1468                                        array(
     1469                                                'key'     => 'mk2',
     1470                                                'value'   => '2',
     1471                                                'compare' => '=',
     1472                                                'type'    => 'numeric',
     1473                                        ),
    12461474                                ),
    1247                                 array(
    1248                                         'key'     => 'mk2',
    1249                                         'value'   => '2',
    1250                                         'compare' => "=",
    1251                                         'type'    => 'numeric',
    1252                                 ),
    1253                         ),
    1254                 ) );
     1475                        )
     1476                );
    12551477
    12561478                // Check results
     
    12631485         */
    12641486        public function test_role_exclusion() {
    1265                 $users = get_users( array(
    1266                         'role__not_in' => 'subscriber',
    1267                 ) );
     1487                $users = get_users(
     1488                        array(
     1489                                'role__not_in' => 'subscriber',
     1490                        )
     1491                );
    12681492
    12691493                // +1 for the default user created during installation.
    12701494                $this->assertEquals( 11, count( $users ) );
    12711495
    1272                 $users = get_users( array(
    1273                         'role__not_in' => 'editor',
    1274                 ) );
     1496                $users = get_users(
     1497                        array(
     1498                                'role__not_in' => 'editor',
     1499                        )
     1500                );
    12751501
    12761502                // +1 for the default user created during installation.
     
    12871513                }
    12881514
    1289                 $users = get_users( array(
    1290                         'role__in'     => 'editor',
    1291                 ) );
     1515                $users = get_users(
     1516                        array(
     1517                                'role__in' => 'editor',
     1518                        )
     1519                );
    12921520
    12931521                $this->assertEquals( 5, count( $users ) );
    12941522
    1295                 $users = get_users( array(
    1296                         'role__in'     => 'editor',
    1297                         'role__not_in' => 'subscriber',
    1298                 ) );
     1523                $users = get_users(
     1524                        array(
     1525                                'role__in'     => 'editor',
     1526                                'role__not_in' => 'subscriber',
     1527                        )
     1528                );
    12991529
    13001530                $this->assertEquals( 3, count( $users ) );
     
    13081538                $subscriber->add_role( 'editor' );
    13091539
    1310                 $users = get_users( array(
    1311                         'role'         => 'subscriber',
    1312                         'role__not_in' => array( 'editor' ),
    1313                 ) );
     1540                $users = get_users(
     1541                        array(
     1542                                'role'         => 'subscriber',
     1543                                'role__not_in' => array( 'editor' ),
     1544                        )
     1545                );
    13141546
    13151547                $this->assertEquals( 1, count( $users ) );
     
    13241556                $user_without_rule->remove_role( 'subscriber' );
    13251557
    1326                 $users = get_users( array(
    1327                         'role__not_in' => 'subscriber',
    1328                 ) );
     1558                $users = get_users(
     1559                        array(
     1560                                'role__not_in' => 'subscriber',
     1561                        )
     1562                );
    13291563
    13301564                // +1 for the default user created during installation.
    13311565                $this->assertEquals( 12, count( $users ) );
    13321566
    1333                 $users = get_users( array(
    1334                         'role__not_in' => 'editor',
    1335                 ) );
     1567                $users = get_users(
     1568                        array(
     1569                                'role__not_in' => 'editor',
     1570                        )
     1571                );
    13361572
    13371573                // +1 for the default user created during installation.
     
    13491585                add_user_to_blog( $sites[1], self::$author_ids[1], 'author' );
    13501586
    1351                 $found = get_users( array(
    1352                         'blog_id' => $sites[1],
    1353                         'fields' => 'ID',
    1354                 ) );
     1587                $found = get_users(
     1588                        array(
     1589                                'blog_id' => $sites[1],
     1590                                'fields'  => 'ID',
     1591                        )
     1592                );
    13551593
    13561594                $this->assertEqualSets( array( self::$author_ids[1] ), $found );
     
    13661604                add_user_to_blog( $site_id, self::$author_ids[0], 'author' );
    13671605
    1368                 $q = new WP_User_Query( array(
    1369                         'include' => self::$author_ids[0],
    1370                 ) );
     1606                $q = new WP_User_Query(
     1607                        array(
     1608                                'include' => self::$author_ids[0],
     1609                        )
     1610                );
    13711611
    13721612                $r1 = $q->request;
    13731613
    1374                 $q->prepare_query( array(
    1375                         'include' => self::$author_ids[0],
    1376                 ) );
     1614                $q->prepare_query(
     1615                        array(
     1616                                'include' => self::$author_ids[0],
     1617                        )
     1618                );
    13771619
    13781620                $r2 = $q->request;
    13791621
    1380                 $q->prepare_query( array(
    1381                         'include' => self::$author_ids[0],
    1382                 ) );
     1622                $q->prepare_query(
     1623                        array(
     1624                                'include' => self::$author_ids[0],
     1625                        )
     1626                );
    13831627
    13841628                $r3 = $q->request;
     
    13931637        public function test_search_by_display_name_only() {
    13941638
    1395                 $new_user1 = $this->factory->user->create( array(
    1396                         'user_login'   => 'name1',
    1397                         'display_name' => 'Sophia Andresen',
    1398                 ) );
     1639                $new_user1          = $this->factory->user->create(
     1640                        array(
     1641                                'user_login'   => 'name1',
     1642                                'display_name' => 'Sophia Andresen',
     1643                        )
     1644                );
    13991645                self::$author_ids[] = $new_user1;
    14001646
    1401                 $q = new WP_User_Query( array(
    1402                         'search' => '*Sophia*',
    1403                         'fields' => '',
    1404                         'search_columns' => array( 'display_name' ),
    1405                         'include' => self::$author_ids,
    1406                 ) );
     1647                $q = new WP_User_Query(
     1648                        array(
     1649                                'search'         => '*Sophia*',
     1650                                'fields'         => '',
     1651                                'search_columns' => array( 'display_name' ),
     1652                                'include'        => self::$author_ids,
     1653                        )
     1654                );
    14071655
    14081656                $ids = $q->get_results();
     
    14171665        public function test_search_by_display_name_only_ignore_others() {
    14181666
    1419                 $new_user1 = $this->factory->user->create( array(
    1420                         'user_login'   => 'Sophia Andresen',
    1421                         'display_name' => 'name1',
    1422                 ) );
     1667                $new_user1          = $this->factory->user->create(
     1668                        array(
     1669                                'user_login'   => 'Sophia Andresen',
     1670                                'display_name' => 'name1',
     1671                        )
     1672                );
    14231673                self::$author_ids[] = $new_user1;
    14241674
    1425                 $q = new WP_User_Query( array(
    1426                         'search' => '*Sophia*',
    1427                         'fields' => '',
    1428                         'search_columns' => array( 'display_name' ),
    1429                         'include' => self::$author_ids,
    1430                 ) );
     1675                $q = new WP_User_Query(
     1676                        array(
     1677                                'search'         => '*Sophia*',
     1678                                'fields'         => '',
     1679                                'search_columns' => array( 'display_name' ),
     1680                                'include'        => self::$author_ids,
     1681                        )
     1682                );
    14311683
    14321684                $ids = $q->get_results();
Note: See TracChangeset for help on using the changeset viewer.