Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (6 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/rest-api/rest-users-controller.php

    r41760 r42343  
    1616    protected static $draft_editor;
    1717    protected static $authors = array();
    18     protected static $posts = array();
     18    protected static $posts   = array();
    1919    protected static $site;
    2020
    2121    public static function wpSetUpBeforeClass( $factory ) {
    22         self::$superadmin = $factory->user->create( array(
    23             'role'       => 'administrator',
    24             'user_login' => 'superadmin',
    25         ) );
    26         self::$user = $factory->user->create( array(
    27             'role' => 'administrator',
    28         ) );
    29         self::$editor = $factory->user->create( array(
    30             'role'       => 'editor',
    31             'user_email' => 'editor@example.com',
    32         ) );
    33         self::$draft_editor = $factory->user->create( array(
    34             'role'       => 'editor',
    35             'user_email' => 'draft-editor@example.com',
    36         ) );
     22        self::$superadmin   = $factory->user->create(
     23            array(
     24                'role'       => 'administrator',
     25                'user_login' => 'superadmin',
     26            )
     27        );
     28        self::$user         = $factory->user->create(
     29            array(
     30                'role' => 'administrator',
     31            )
     32        );
     33        self::$editor       = $factory->user->create(
     34            array(
     35                'role'       => 'editor',
     36                'user_email' => 'editor@example.com',
     37            )
     38        );
     39        self::$draft_editor = $factory->user->create(
     40            array(
     41                'role'       => 'editor',
     42                'user_email' => 'draft-editor@example.com',
     43            )
     44        );
    3745
    3846        foreach ( array( true, false ) as $show_in_rest ) {
    3947            foreach ( array( true, false ) as $public ) {
    4048                $post_type_name = 'r_' . json_encode( $show_in_rest ) . '_p_' . json_encode( $public );
    41                 register_post_type( $post_type_name, array(
    42                     'public'                   => $public,
    43                     'show_in_rest'             => $show_in_rest,
    44                     'tests_no_auto_unregister' => true,
    45                 ) );
    46                 self::$authors[ $post_type_name ] = $factory->user->create( array(
    47                     'role'       => 'editor',
    48                     'user_email' => 'author_' . $post_type_name . '@example.com',
    49                 ) );
    50                 self::$posts[ $post_type_name ] = $factory->post->create( array(
    51                     'post_type'   => $post_type_name,
    52                     'post_author' => self::$authors[ $post_type_name ],
    53                 ) );
     49                register_post_type(
     50                    $post_type_name, array(
     51                        'public'                   => $public,
     52                        'show_in_rest'             => $show_in_rest,
     53                        'tests_no_auto_unregister' => true,
     54                    )
     55                );
     56                self::$authors[ $post_type_name ] = $factory->user->create(
     57                    array(
     58                        'role'       => 'editor',
     59                        'user_email' => 'author_' . $post_type_name . '@example.com',
     60                    )
     61                );
     62                self::$posts[ $post_type_name ]   = $factory->post->create(
     63                    array(
     64                        'post_type'   => $post_type_name,
     65                        'post_author' => self::$authors[ $post_type_name ],
     66                    )
     67                );
    5468            }
    5569        }
    5670
    57         self::$posts['post'] = $factory->post->create( array(
    58             'post_type'   => 'post',
    59             'post_author' => self::$editor,
    60         ) );
    61         self::$posts['r_true_p_true_DRAFT'] = $factory->post->create( array(
    62             'post_type'   => 'r_true_p_true',
    63             'post_author' => self::$draft_editor,
    64             'post_status' => 'draft',
    65         ) );
     71        self::$posts['post']                = $factory->post->create(
     72            array(
     73                'post_type'   => 'post',
     74                'post_author' => self::$editor,
     75            )
     76        );
     77        self::$posts['r_true_p_true_DRAFT'] = $factory->post->create(
     78            array(
     79                'post_type'   => 'r_true_p_true',
     80                'post_author' => self::$draft_editor,
     81                'post_status' => 'draft',
     82            )
     83        );
    6684
    6785        if ( is_multisite() ) {
    68             self::$site = $factory->blog->create( array( 'domain' => 'rest.wordpress.org', 'path' => '/' ) );
     86            self::$site = $factory->blog->create(
     87                array(
     88                    'domain' => 'rest.wordpress.org',
     89                    'path'   => '/',
     90                )
     91            );
    6992            update_site_option( 'site_admins', array( 'superadmin' ) );
    7093        }
     
    112135    public function test_context_param() {
    113136        // Collection
    114         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
    115         $response = $this->server->dispatch( $request );
    116         $data = $response->get_data();
     137        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
     138        $response = $this->server->dispatch( $request );
     139        $data     = $response->get_data();
    117140        $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
    118141        $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    119142        // Single
    120         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users/' . self::$user );
    121         $response = $this->server->dispatch( $request );
    122         $data = $response->get_data();
     143        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/users/' . self::$user );
     144        $response = $this->server->dispatch( $request );
     145        $data     = $response->get_data();
    123146        $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
    124147        $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
     
    126149
    127150    public function test_registered_query_params() {
    128         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
    129         $response = $this->server->dispatch( $request );
    130         $data = $response->get_data();
    131         $keys = array_keys( $data['endpoints'][0]['args'] );
     151        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
     152        $response = $this->server->dispatch( $request );
     153        $data     = $response->get_data();
     154        $keys     = array_keys( $data['endpoints'][0]['args'] );
    132155        sort( $keys );
    133         $this->assertEquals( array(
    134             'context',
    135             'exclude',
    136             'include',
    137             'offset',
    138             'order',
    139             'orderby',
    140             'page',
    141             'per_page',
    142             'roles',
    143             'search',
    144             'slug',
    145             ), $keys );
     156        $this->assertEquals(
     157            array(
     158                'context',
     159                'exclude',
     160                'include',
     161                'offset',
     162                'order',
     163                'orderby',
     164                'page',
     165                'per_page',
     166                'roles',
     167                'search',
     168                'slug',
     169            ), $keys
     170        );
    146171    }
    147172
     
    156181
    157182        $all_data = $response->get_data();
    158         $data = $all_data[0];
     183        $data     = $all_data[0];
    159184        $userdata = get_userdata( $data['id'] );
    160185        $this->check_user_data( $userdata, $data, 'view', $data['_links'] );
     
    171196
    172197        $all_data = $response->get_data();
    173         $data = $all_data[0];
     198        $data     = $all_data[0];
    174199        $userdata = get_userdata( $data['id'] );
    175200        $this->check_user_data( $userdata, $data, 'edit', $data['_links'] );
     
    194219
    195220    public function test_get_items_unauthenticated_includes_authors_of_post_types_shown_in_rest() {
    196         $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    197         $response = $this->server->dispatch( $request );
    198         $users = $response->get_data();
     221        $request  = new WP_REST_Request( 'GET', '/wp/v2/users' );
     222        $response = $this->server->dispatch( $request );
     223        $users    = $response->get_data();
    199224
    200225        $rest_post_types = array_values( get_post_types( array( 'show_in_rest' => true ), 'names' ) );
     
    218243        $user_ids = wp_list_pluck( $users, 'id' );
    219244
    220         $this->assertTrue( in_array( self::$editor                   , $user_ids, true ) );
    221         $this->assertTrue( in_array( self::$authors['r_true_p_true'] , $user_ids, true ) );
     245        $this->assertTrue( in_array( self::$editor, $user_ids, true ) );
     246        $this->assertTrue( in_array( self::$authors['r_true_p_true'], $user_ids, true ) );
    222247        $this->assertTrue( in_array( self::$authors['r_true_p_false'], $user_ids, true ) );
    223248        $this->assertCount( 3, $user_ids );
     
    225250
    226251    public function test_get_items_unauthenticated_does_not_include_authors_of_post_types_not_shown_in_rest() {
    227         $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    228         $response = $this->server->dispatch( $request );
    229         $users = $response->get_data();
     252        $request  = new WP_REST_Request( 'GET', '/wp/v2/users' );
     253        $response = $this->server->dispatch( $request );
     254        $users    = $response->get_data();
    230255        $user_ids = wp_list_pluck( $users, 'id' );
    231256
    232         $this->assertFalse( in_array( self::$authors['r_false_p_true'] , $user_ids, true ) );
     257        $this->assertFalse( in_array( self::$authors['r_false_p_true'], $user_ids, true ) );
    233258        $this->assertFalse( in_array( self::$authors['r_false_p_false'], $user_ids, true ) );
    234259    }
    235260
    236261    public function test_get_items_unauthenticated_does_not_include_users_without_published_posts() {
    237         $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    238         $response = $this->server->dispatch( $request );
    239         $users = $response->get_data();
     262        $request  = new WP_REST_Request( 'GET', '/wp/v2/users' );
     263        $response = $this->server->dispatch( $request );
     264        $users    = $response->get_data();
    240265        $user_ids = wp_list_pluck( $users, 'id' );
    241266
    242267        $this->assertFalse( in_array( self::$draft_editor, $user_ids, true ) );
    243         $this->assertFalse( in_array( self::$user        , $user_ids, true ) );
     268        $this->assertFalse( in_array( self::$user, $user_ids, true ) );
    244269    }
    245270
     
    247272        wp_set_current_user( self::$user );
    248273        for ( $i = 0; $i < 44; $i++ ) {
    249             $this->factory->user->create( array(
    250                 'name' => "User {$i}",
    251             ) );
    252         }
    253         $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    254         $response = $this->server->dispatch( $request );
    255         $headers = $response->get_headers();
     274            $this->factory->user->create(
     275                array(
     276                    'name' => "User {$i}",
     277                )
     278            );
     279        }
     280        $request  = new WP_REST_Request( 'GET', '/wp/v2/users' );
     281        $response = $this->server->dispatch( $request );
     282        $headers  = $response->get_headers();
    256283        $this->assertEquals( 53, $headers['X-WP-Total'] );
    257284        $this->assertEquals( 6, $headers['X-WP-TotalPages'] );
    258         $next_link = add_query_arg( array(
    259             'page'    => 2,
    260             ), rest_url( 'wp/v2/users' ) );
     285        $next_link = add_query_arg(
     286            array(
     287                'page' => 2,
     288            ), rest_url( 'wp/v2/users' )
     289        );
    261290        $this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) );
    262291        $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
    263292        // 3rd page
    264         $this->factory->user->create( array(
    265                 'name'   => 'User 51',
    266                 ) );
     293        $this->factory->user->create(
     294            array(
     295                'name' => 'User 51',
     296            )
     297        );
    267298        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    268299        $request->set_param( 'page', 3 );
    269300        $response = $this->server->dispatch( $request );
    270         $headers = $response->get_headers();
     301        $headers  = $response->get_headers();
    271302        $this->assertEquals( 54, $headers['X-WP-Total'] );
    272303        $this->assertEquals( 6, $headers['X-WP-TotalPages'] );
    273         $prev_link = add_query_arg( array(
    274             'page'    => 2,
    275             ), rest_url( 'wp/v2/users' ) );
     304        $prev_link = add_query_arg(
     305            array(
     306                'page' => 2,
     307            ), rest_url( 'wp/v2/users' )
     308        );
    276309        $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    277         $next_link = add_query_arg( array(
    278             'page'    => 4,
    279             ), rest_url( 'wp/v2/users' ) );
     310        $next_link = add_query_arg(
     311            array(
     312                'page' => 4,
     313            ), rest_url( 'wp/v2/users' )
     314        );
    280315        $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
    281316        // Last page
     
    283318        $request->set_param( 'page', 6 );
    284319        $response = $this->server->dispatch( $request );
    285         $headers = $response->get_headers();
     320        $headers  = $response->get_headers();
    286321        $this->assertEquals( 54, $headers['X-WP-Total'] );
    287322        $this->assertEquals( 6, $headers['X-WP-TotalPages'] );
    288         $prev_link = add_query_arg( array(
    289             'page'    => 5,
    290             ), rest_url( 'wp/v2/users' ) );
     323        $prev_link = add_query_arg(
     324            array(
     325                'page' => 5,
     326            ), rest_url( 'wp/v2/users' )
     327        );
    291328        $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    292329        $this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
     
    295332        $request->set_param( 'page', 8 );
    296333        $response = $this->server->dispatch( $request );
    297         $headers = $response->get_headers();
     334        $headers  = $response->get_headers();
    298335        $this->assertEquals( 54, $headers['X-WP-Total'] );
    299336        $this->assertEquals( 6, $headers['X-WP-TotalPages'] );
    300         $prev_link = add_query_arg( array(
    301             'page'    => 6,
    302             ), rest_url( 'wp/v2/users' ) );
     337        $prev_link = add_query_arg(
     338            array(
     339                'page' => 6,
     340            ), rest_url( 'wp/v2/users' )
     341        );
    303342        $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    304343        $this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
     
    310349            $this->factory->user->create( array( 'display_name' => "User {$i}" ) );
    311350        }
    312         $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     351        $request  = new WP_REST_Request( 'GET', '/wp/v2/users' );
    313352        $response = $this->server->dispatch( $request );
    314353        $this->assertEquals( 10, count( $response->get_data() ) );
     
    329368        $response = $this->server->dispatch( $request );
    330369        $this->assertEquals( 5, count( $response->get_data() ) );
    331         $prev_link = add_query_arg( array(
    332             'per_page'  => 5,
    333             'page'      => 1,
    334             ), rest_url( 'wp/v2/users' ) );
    335         $headers = $response->get_headers();
     370        $prev_link = add_query_arg(
     371            array(
     372                'per_page' => 5,
     373                'page'     => 1,
     374            ), rest_url( 'wp/v2/users' )
     375        );
     376        $headers   = $response->get_headers();
    336377        $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    337378    }
     
    339380    public function test_get_items_orderby_name() {
    340381        wp_set_current_user( self::$user );
    341         $low_id = $this->factory->user->create( array( 'display_name' => 'AAAAA' ) );
    342         $mid_id = $this->factory->user->create( array( 'display_name' => 'NNNNN' ) );
     382        $low_id  = $this->factory->user->create( array( 'display_name' => 'AAAAA' ) );
     383        $mid_id  = $this->factory->user->create( array( 'display_name' => 'NNNNN' ) );
    343384        $high_id = $this->factory->user->create( array( 'display_name' => 'ZZZZ' ) );
    344385        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    347388        $request->set_param( 'per_page', 1 );
    348389        $response = $this->server->dispatch( $request );
    349         $data = $response->get_data();
     390        $data     = $response->get_data();
    350391        $this->assertEquals( $high_id, $data[0]['id'] );
    351392        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    354395        $request->set_param( 'per_page', 1 );
    355396        $response = $this->server->dispatch( $request );
    356         $data = $response->get_data();
     397        $data     = $response->get_data();
    357398        $this->assertEquals( $low_id, $data[0]['id'] );
    358399    }
     
    361402        wp_set_current_user( self::$user );
    362403
    363         $low_id = $this->factory->user->create( array( 'user_url' => 'http://a.com' ) );
     404        $low_id  = $this->factory->user->create( array( 'user_url' => 'http://a.com' ) );
    364405        $high_id = $this->factory->user->create( array( 'user_url' => 'http://b.com' ) );
    365406
     
    370411        $request->set_param( 'include', array( $low_id, $high_id ) );
    371412        $response = $this->server->dispatch( $request );
    372         $data = $response->get_data();
     413        $data     = $response->get_data();
    373414
    374415        $this->assertEquals( $high_id, $data[0]['id'] );
     
    380421        $request->set_param( 'include', array( $low_id, $high_id ) );
    381422        $response = $this->server->dispatch( $request );
    382         $data = $response->get_data();
     423        $data     = $response->get_data();
    383424        $this->assertEquals( $low_id, $data[0]['id'] );
    384425    }
     
    388429
    389430        $high_id = $this->factory->user->create( array( 'user_nicename' => 'blogin' ) );
    390         $low_id = $this->factory->user->create( array( 'user_nicename' => 'alogin' ) );
     431        $low_id  = $this->factory->user->create( array( 'user_nicename' => 'alogin' ) );
    391432
    392433        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    396437        $request->set_param( 'include', array( $low_id, $high_id ) );
    397438        $response = $this->server->dispatch( $request );
    398         $data = $response->get_data();
     439        $data     = $response->get_data();
    399440
    400441        $this->assertEquals( $high_id, $data[0]['id'] );
     
    406447        $request->set_param( 'include', array( $low_id, $high_id ) );
    407448        $response = $this->server->dispatch( $request );
    408         $data = $response->get_data();
     449        $data     = $response->get_data();
    409450        $this->assertEquals( $low_id, $data[0]['id'] );
    410451    }
     
    421462        $request->set_param( 'slug', array( 'taco', 'burrito', 'chalupa' ) );
    422463        $response = $this->server->dispatch( $request );
    423         $data = $response->get_data();
     464        $data     = $response->get_data();
    424465
    425466        $this->assertEquals( 'taco', $data[0]['slug'] );
     
    432473
    433474        $high_id = $this->factory->user->create( array( 'user_email' => 'bemail@gmail.com' ) );
    434         $low_id = $this->factory->user->create( array( 'user_email' => 'aemail@gmail.com' ) );
     475        $low_id  = $this->factory->user->create( array( 'user_email' => 'aemail@gmail.com' ) );
    435476
    436477        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     
    440481        $request->set_param( 'include', array( $low_id, $high_id ) );
    441482        $response = $this->server->dispatch( $request );
    442         $data = $response->get_data();
     483        $data     = $response->get_data();
    443484        $this->assertEquals( $high_id, $data[0]['id'] );
    444485
     
    449490        $request->set_param( 'include', array( $low_id, $high_id ) );
    450491        $response = $this->server->dispatch( $request );
    451         $data = $response->get_data();
     492        $data     = $response->get_data();
    452493        $this->assertEquals( $low_id, $data[0]['id'] );
    453494    }
     
    507548    public function test_get_items_include_query() {
    508549        wp_set_current_user( self::$user );
    509         $id1 = $this->factory->user->create();
    510         $id2 = $this->factory->user->create();
    511         $id3 = $this->factory->user->create();
     550        $id1     = $this->factory->user->create();
     551        $id2     = $this->factory->user->create();
     552        $id3     = $this->factory->user->create();
    512553        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    513554        // Orderby=>asc
    514555        $request->set_param( 'include', array( $id3, $id1 ) );
    515556        $response = $this->server->dispatch( $request );
    516         $data = $response->get_data();
     557        $data     = $response->get_data();
    517558        $this->assertEquals( 2, count( $data ) );
    518559        $this->assertEquals( $id1, $data[0]['id'] );
     
    520561        $request->set_param( 'orderby', 'include' );
    521562        $response = $this->server->dispatch( $request );
    522         $data = $response->get_data();
     563        $data     = $response->get_data();
    523564        $this->assertEquals( 2, count( $data ) );
    524565        $this->assertEquals( $id3, $data[0]['id'] );
     
    531572        wp_set_current_user( 0 );
    532573        $response = $this->server->dispatch( $request );
    533         $data = $response->get_data();
     574        $data     = $response->get_data();
    534575        $this->assertEquals( 0, count( $data ) );
    535576
     
    538579    public function test_get_items_exclude_query() {
    539580        wp_set_current_user( self::$user );
    540         $id1 = $this->factory->user->create();
    541         $id2 = $this->factory->user->create();
     581        $id1     = $this->factory->user->create();
     582        $id2     = $this->factory->user->create();
    542583        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    543584        $request->set_param( 'per_page', 20 ); // there are >10 users at this point
    544585        $response = $this->server->dispatch( $request );
    545         $data = $response->get_data();
     586        $data     = $response->get_data();
    546587        $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    547588        $this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
    548589        $request->set_param( 'exclude', array( $id2 ) );
    549590        $response = $this->server->dispatch( $request );
    550         $data = $response->get_data();
     591        $data     = $response->get_data();
    551592        $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    552593        $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
     
    569610        $this->assertEquals( 1, count( $response->get_data() ) );
    570611        // default to wildcard search
    571         $adam_id = $this->factory->user->create( array(
    572             'role'          => 'author',
    573             'user_nicename' => 'adam',
    574         ) );
     612        $adam_id = $this->factory->user->create(
     613            array(
     614                'role'          => 'author',
     615                'user_nicename' => 'adam',
     616            )
     617        );
    575618        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    576619        $request->set_param( 'search', 'ada' );
    577620        $response = $this->server->dispatch( $request );
    578         $data = $response->get_data();
     621        $data     = $response->get_data();
    579622        $this->assertEquals( 1, count( $data ) );
    580623        $this->assertEquals( $adam_id, $data[0]['id'] );
     
    583626    public function test_get_items_slug_query() {
    584627        wp_set_current_user( self::$user );
    585         $this->factory->user->create( array( 'display_name' => 'foo', 'user_login' => 'bar' ) );
    586         $id2 = $this->factory->user->create( array( 'display_name' => 'Moo', 'user_login' => 'foo' ) );
     628        $this->factory->user->create(
     629            array(
     630                'display_name' => 'foo',
     631                'user_login'   => 'bar',
     632            )
     633        );
     634        $id2     = $this->factory->user->create(
     635            array(
     636                'display_name' => 'Moo',
     637                'user_login'   => 'foo',
     638            )
     639        );
    587640        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    588641        $request->set_param( 'slug', 'foo' );
    589642        $response = $this->server->dispatch( $request );
    590         $data = $response->get_data();
     643        $data     = $response->get_data();
    591644        $this->assertEquals( 1, count( $data ) );
    592645        $this->assertEquals( $id2, $data[0]['id'] );
     
    595648    public function test_get_items_slug_array_query() {
    596649        wp_set_current_user( self::$user );
    597         $id1 = $this->factory->user->create( array(
    598             'display_name' => 'Taco',
    599             'user_login'   => 'taco'
    600         ) );
    601         $id2 = $this->factory->user->create( array(
    602             'display_name' => 'Enchilada',
    603             'user_login'   => 'enchilada'
    604         ) );
    605         $id3 = $this->factory->user->create( array(
    606             'display_name' => 'Burrito',
    607             'user_login'   => 'burrito'
    608         ) );
    609         $this->factory->user->create( array(
    610             'display_name' => 'Hon Pizza',
    611             'user_login'   => 'pizza'
    612         ) );
    613         $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    614         $request->set_param( 'slug', array(
    615             'taco',
    616             'burrito',
    617             'enchilada',
    618         ) );
     650        $id1 = $this->factory->user->create(
     651            array(
     652                'display_name' => 'Taco',
     653                'user_login'   => 'taco',
     654            )
     655        );
     656        $id2 = $this->factory->user->create(
     657            array(
     658                'display_name' => 'Enchilada',
     659                'user_login'   => 'enchilada',
     660            )
     661        );
     662        $id3 = $this->factory->user->create(
     663            array(
     664                'display_name' => 'Burrito',
     665                'user_login'   => 'burrito',
     666            )
     667        );
     668        $this->factory->user->create(
     669            array(
     670                'display_name' => 'Hon Pizza',
     671                'user_login'   => 'pizza',
     672            )
     673        );
     674        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     675        $request->set_param(
     676            'slug', array(
     677                'taco',
     678                'burrito',
     679                'enchilada',
     680            )
     681        );
    619682        $request->set_param( 'orderby', 'slug' );
    620683        $request->set_param( 'order', 'asc' );
    621684        $response = $this->server->dispatch( $request );
    622685        $this->assertEquals( 200, $response->get_status() );
    623         $data = $response->get_data();
     686        $data  = $response->get_data();
    624687        $slugs = wp_list_pluck( $data, 'slug' );
    625688        $this->assertEquals( array( 'burrito', 'enchilada', 'taco' ), $slugs );
     
    628691    public function test_get_items_slug_csv_query() {
    629692        wp_set_current_user( self::$user );
    630         $id1 = $this->factory->user->create( array(
    631             'display_name' => 'Taco',
    632             'user_login'   => 'taco'
    633         ) );
    634         $id2 = $this->factory->user->create( array(
    635             'display_name' => 'Enchilada',
    636             'user_login'   => 'enchilada'
    637         ) );
    638         $id3 = $this->factory->user->create( array(
    639             'display_name' => 'Burrito',
    640             'user_login'   => 'burrito'
    641         ) );
    642         $this->factory->user->create( array(
    643             'display_name' => 'Hon Pizza',
    644             'user_login'   => 'pizza'
    645         ) );
    646         $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    647         $request->set_param( 'slug', 'taco,burrito , enchilada');
     693        $id1 = $this->factory->user->create(
     694            array(
     695                'display_name' => 'Taco',
     696                'user_login'   => 'taco',
     697            )
     698        );
     699        $id2 = $this->factory->user->create(
     700            array(
     701                'display_name' => 'Enchilada',
     702                'user_login'   => 'enchilada',
     703            )
     704        );
     705        $id3 = $this->factory->user->create(
     706            array(
     707                'display_name' => 'Burrito',
     708                'user_login'   => 'burrito',
     709            )
     710        );
     711        $this->factory->user->create(
     712            array(
     713                'display_name' => 'Hon Pizza',
     714                'user_login'   => 'pizza',
     715            )
     716        );
     717        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     718        $request->set_param( 'slug', 'taco,burrito , enchilada' );
    648719        $request->set_param( 'orderby', 'slug' );
    649720        $request->set_param( 'order', 'desc' );
    650721        $response = $this->server->dispatch( $request );
    651722        $this->assertEquals( 200, $response->get_status() );
    652         $data = $response->get_data();
     723        $data  = $response->get_data();
    653724        $slugs = wp_list_pluck( $data, 'slug' );
    654725        $this->assertEquals( array( 'taco', 'enchilada', 'burrito' ), $slugs );
     
    658729    public function test_get_items_roles() {
    659730        wp_set_current_user( self::$user );
    660         $tango = $this->factory->user->create( array( 'display_name' => 'tango', 'role' => 'subscriber' ) );
    661         $yolo  = $this->factory->user->create( array( 'display_name' => 'yolo', 'role' => 'author' ) );
     731        $tango   = $this->factory->user->create(
     732            array(
     733                'display_name' => 'tango',
     734                'role'         => 'subscriber',
     735            )
     736        );
     737        $yolo    = $this->factory->user->create(
     738            array(
     739                'display_name' => 'yolo',
     740                'role'         => 'author',
     741            )
     742        );
    662743        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    663744        $request->set_param( 'roles', 'author,subscriber' );
    664745        $response = $this->server->dispatch( $request );
    665         $data = $response->get_data();
     746        $data     = $response->get_data();
    666747        $this->assertEquals( 2, count( $data ) );
    667748        $this->assertEquals( $tango, $data[0]['id'] );
     
    669750        $request->set_param( 'roles', 'author' );
    670751        $response = $this->server->dispatch( $request );
    671         $data = $response->get_data();
     752        $data     = $response->get_data();
    672753        $this->assertEquals( 1, count( $data ) );
    673754        $this->assertEquals( $yolo, $data[0]['id'] );
     
    684765    public function test_get_items_invalid_roles() {
    685766        wp_set_current_user( self::$user );
    686         $lolz = $this->factory->user->create( array( 'display_name' => 'lolz', 'role' => 'author' ) );
     767        $lolz    = $this->factory->user->create(
     768            array(
     769                'display_name' => 'lolz',
     770                'role'         => 'author',
     771            )
     772        );
    687773        $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
    688774        $request->set_param( 'roles', 'ilovesteak,author' );
    689775        $response = $this->server->dispatch( $request );
    690         $data = $response->get_data();
     776        $data     = $response->get_data();
    691777        $this->assertEquals( 1, count( $data ) );
    692778        $this->assertEquals( $lolz, $data[0]['id'] );
     
    694780        $request->set_param( 'roles', 'steakisgood' );
    695781        $response = $this->server->dispatch( $request );
    696         $data = $response->get_data();
     782        $data     = $response->get_data();
    697783        $this->assertEquals( 0, count( $data ) );
    698784        $this->assertEquals( array(), $data );
     
    726812
    727813        $data = $response->get_data();
    728         $this->assertArrayHasKey( 24,  $data['avatar_urls'] );
    729         $this->assertArrayHasKey( 48,  $data['avatar_urls'] );
    730         $this->assertArrayHasKey( 96,  $data['avatar_urls'] );
     814        $this->assertArrayHasKey( 24, $data['avatar_urls'] );
     815        $this->assertArrayHasKey( 48, $data['avatar_urls'] );
     816        $this->assertArrayHasKey( 96, $data['avatar_urls'] );
    731817
    732818        $user = get_user_by( 'id', self::$editor );
     
    740826    public function test_get_user_invalid_id() {
    741827        wp_set_current_user( self::$user );
    742         $request = new WP_REST_Request( 'GET', '/wp/v2/users/100' );
     828        $request  = new WP_REST_Request( 'GET', '/wp/v2/users/100' );
    743829        $response = $this->server->dispatch( $request );
    744830
     
    750836        $this->allow_user_to_manage_multisite();
    751837
    752         $lolz = $this->factory->user->create( array( 'display_name' => 'lolz', 'roles' => '' ) );
     838        $lolz = $this->factory->user->create(
     839            array(
     840                'display_name' => 'lolz',
     841                'roles'        => '',
     842            )
     843        );
    753844        delete_user_option( $lolz, 'capabilities' );
    754845        delete_user_option( $lolz, 'user_level' );
     
    769860    public function test_cannot_get_item_without_permission() {
    770861        wp_set_current_user( self::$editor );
    771         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$user ) );
     862        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$user ) );
    772863        $response = $this->server->dispatch( $request );
    773864        $this->assertErrorResponse( 'rest_user_cannot_view', $response, 403 );
     
    775866
    776867    public function test_can_get_item_author_of_rest_true_public_true_unauthenticated() {
    777         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) );
     868        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) );
    778869        $response = $this->server->dispatch( $request );
    779870        $this->assertEquals( 200, $response->get_status() );
     
    782873    public function test_can_get_item_author_of_rest_true_public_true_authenticated() {
    783874        wp_set_current_user( self::$editor );
    784         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) );
     875        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) );
    785876        $response = $this->server->dispatch( $request );
    786877        $this->assertEquals( 200, $response->get_status() );
     
    788879
    789880    public function test_can_get_item_author_of_rest_true_public_false() {
    790         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_false'] ) );
     881        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_false'] ) );
    791882        $response = $this->server->dispatch( $request );
    792883        $this->assertEquals( 200, $response->get_status() );
     
    794885
    795886    public function test_cannot_get_item_author_of_rest_false_public_true_unauthenticated() {
    796         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_false_p_true'] ) );
     887        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_false_p_true'] ) );
    797888        $response = $this->server->dispatch( $request );
    798889        $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 );
     
    801892    public function test_cannot_get_item_author_of_rest_false_public_true_without_permission() {
    802893        wp_set_current_user( self::$editor );
    803         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_false_p_true'] ) );
     894        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_false_p_true'] ) );
    804895        $response = $this->server->dispatch( $request );
    805896        $this->assertErrorResponse( 'rest_user_cannot_view', $response, 403 );
     
    807898
    808899    public function test_cannot_get_item_author_of_rest_false_public_false() {
    809         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_false_p_false'] ) );
     900        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_false_p_false'] ) );
    810901        $response = $this->server->dispatch( $request );
    811902        $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 );
     
    813904
    814905    public function test_can_get_item_author_of_post() {
    815         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$editor ) );
     906        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$editor ) );
    816907        $response = $this->server->dispatch( $request );
    817908        $this->assertEquals( 200, $response->get_status() );
     
    819910
    820911    public function test_cannot_get_item_author_of_draft() {
    821         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$draft_editor ) );
     912        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$draft_editor ) );
    822913        $response = $this->server->dispatch( $request );
    823914        $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 );
     
    825916
    826917    public function test_get_item_published_author_post() {
    827         $this->author_id = $this->factory->user->create( array(
    828             'role' => 'author',
    829         ) );
    830         $this->post_id = $this->factory->post->create( array(
    831             'post_author' => $this->author_id,
    832         ));
     918        $this->author_id = $this->factory->user->create(
     919            array(
     920                'role' => 'author',
     921            )
     922        );
     923        $this->post_id   = $this->factory->post->create(
     924            array(
     925                'post_author' => $this->author_id,
     926            )
     927        );
    833928        wp_set_current_user( 0 );
    834         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->author_id ) );
     929        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->author_id ) );
    835930        $response = $this->server->dispatch( $request );
    836931        $this->check_get_user_response( $response, 'embed' );
     
    838933
    839934    public function test_get_item_published_author_pages() {
    840         $this->author_id = $this->factory->user->create( array(
    841             'role' => 'author',
    842         ) );
     935        $this->author_id = $this->factory->user->create(
     936            array(
     937                'role' => 'author',
     938            )
     939        );
    843940        wp_set_current_user( 0 );
    844         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->author_id ) );
     941        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->author_id ) );
    845942        $response = $this->server->dispatch( $request );
    846943        $this->assertEquals( 401, $response->get_status() );
    847         $this->post_id = $this->factory->post->create( array(
    848             'post_author' => $this->author_id,
    849             'post_type'   => 'page',
    850         ));
    851         $response = $this->server->dispatch( $request );
     944        $this->post_id = $this->factory->post->create(
     945            array(
     946                'post_author' => $this->author_id,
     947                'post_type'   => 'page',
     948            )
     949        );
     950        $response      = $this->server->dispatch( $request );
    852951        $this->check_get_user_response( $response, 'embed' );
    853952    }
     
    865964
    866965    public function test_get_item_published_author_wrong_context() {
    867         $this->author_id = $this->factory->user->create( array(
    868             'role' => 'author',
    869         ) );
    870         $this->post_id = $this->factory->post->create( array(
    871             'post_author' => $this->author_id,
    872         ));
     966        $this->author_id = $this->factory->user->create(
     967            array(
     968                'role' => 'author',
     969            )
     970        );
     971        $this->post_id   = $this->factory->post->create(
     972            array(
     973                'post_author' => $this->author_id,
     974            )
     975        );
    873976        wp_set_current_user( 0 );
    874977        $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->author_id ) );
     
    896999    public function test_get_current_user_without_permission() {
    8971000        wp_set_current_user( 0 );
    898         $request = new WP_REST_Request( 'GET', '/wp/v2/users/me' );
     1001        $request  = new WP_REST_Request( 'GET', '/wp/v2/users/me' );
    8991002        $response = $this->server->dispatch( $request );
    9001003
     
    9231026
    9241027        $response = $this->server->dispatch( $request );
    925         $data = $response->get_data();
     1028        $data     = $response->get_data();
    9261029        $this->assertEquals( 'http://example.com', $data['url'] );
    9271030        $this->assertEquals( array( 'editor' ), $data['roles'] );
     
    10291132        $request->set_body_params( $params );
    10301133        $response = $this->server->dispatch( $request );
    1031         $data = $response->get_data();
    1032         $user_id = $data['id'];
     1134        $data     = $response->get_data();
     1135        $user_id  = $data['id'];
    10331136
    10341137        $user_is_member = is_user_member_of_blog( $user_id, self::$site );
     
    10831186        $request->set_body_params( $params );
    10841187        $response = $this->server->dispatch( $request );
    1085         $data = $response->get_data();
    1086         $user_id = $data['id'];
     1188        $data     = $response->get_data();
     1189        $user_id  = $data['id'];
    10871190
    10881191        restore_current_blog();
     
    11131216        $request->set_body_params( $params );
    11141217        $response = $this->server->dispatch( $request );
    1115         $data = $response->get_data();
    1116         $user_id = $data['id'];
     1218        $data     = $response->get_data();
     1219        $user_id  = $data['id'];
    11171220
    11181221        switch_to_blog( self::$site );
     
    12351338
    12361339    public function test_update_item() {
    1237         $user_id = $this->factory->user->create( array(
    1238             'user_email' => 'test@example.com',
    1239             'user_pass' => 'sjflsfls',
    1240             'user_login' => 'test_update',
    1241             'first_name' => 'Old Name',
    1242             'user_url' => 'http://apple.com',
    1243             'locale' => 'en_US',
    1244         ));
    1245         $this->allow_user_to_manage_multisite();
    1246         wp_set_current_user( self::$user );
    1247 
    1248         $userdata = get_userdata( $user_id );
     1340        $user_id = $this->factory->user->create(
     1341            array(
     1342                'user_email' => 'test@example.com',
     1343                'user_pass'  => 'sjflsfls',
     1344                'user_login' => 'test_update',
     1345                'first_name' => 'Old Name',
     1346                'user_url'   => 'http://apple.com',
     1347                'locale'     => 'en_US',
     1348            )
     1349        );
     1350        $this->allow_user_to_manage_multisite();
     1351        wp_set_current_user( self::$user );
     1352
     1353        $userdata  = get_userdata( $user_id );
    12491354        $pw_before = $userdata->user_pass;
    12501355
    1251         $_POST['email'] = $userdata->user_email;
    1252         $_POST['username'] = $userdata->user_login;
     1356        $_POST['email']      = $userdata->user_email;
     1357        $_POST['username']   = $userdata->user_login;
    12531358        $_POST['first_name'] = 'New Name';
    1254         $_POST['url'] = 'http://google.com';
    1255         $_POST['locale'] = 'de_DE';
     1359        $_POST['url']        = 'http://google.com';
     1360        $_POST['locale']     = 'de_DE';
    12561361
    12571362        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) );
     
    12951400
    12961401    public function test_update_item_existing_email() {
    1297         $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
    1298         $user2 = $this->factory->user->create( array( 'user_login' => 'test_json_user2', 'user_email' => 'testjson2@example.com' ) );
     1402        $user1 = $this->factory->user->create(
     1403            array(
     1404                'user_login' => 'test_json_user',
     1405                'user_email' => 'testjson@example.com',
     1406            )
     1407        );
     1408        $user2 = $this->factory->user->create(
     1409            array(
     1410                'user_login' => 'test_json_user2',
     1411                'user_email' => 'testjson2@example.com',
     1412            )
     1413        );
    12991414        $this->allow_user_to_manage_multisite();
    13001415        wp_set_current_user( self::$user );
     
    13081423
    13091424    public function test_update_item_invalid_locale() {
    1310         $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
     1425        $user1 = $this->factory->user->create(
     1426            array(
     1427                'user_login' => 'test_json_user',
     1428                'user_email' => 'testjson@example.com',
     1429            )
     1430        );
    13111431        $this->allow_user_to_manage_multisite();
    13121432        wp_set_current_user( self::$user );
     
    13201440
    13211441    public function test_update_item_en_US_locale() {
    1322         $user_id = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
     1442        $user_id = $this->factory->user->create(
     1443            array(
     1444                'user_login' => 'test_json_user',
     1445                'user_email' => 'testjson@example.com',
     1446            )
     1447        );
    13231448        $this->allow_user_to_manage_multisite();
    13241449        wp_set_current_user( self::$user );
     
    13371462     */
    13381463    public function test_update_item_empty_locale() {
    1339         $user_id = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com', 'locale' => 'de_DE' ) );
     1464        $user_id = $this->factory->user->create(
     1465            array(
     1466                'user_login' => 'test_json_user',
     1467                'user_email' => 'testjson@example.com',
     1468                'locale'     => 'de_DE',
     1469            )
     1470        );
    13401471        $this->allow_user_to_manage_multisite();
    13411472        wp_set_current_user( self::$user );
     
    13531484
    13541485    public function test_update_item_username_attempt() {
    1355         $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
    1356         $user2 = $this->factory->user->create( array( 'user_login' => 'test_json_user2', 'user_email' => 'testjson2@example.com' ) );
     1486        $user1 = $this->factory->user->create(
     1487            array(
     1488                'user_login' => 'test_json_user',
     1489                'user_email' => 'testjson@example.com',
     1490            )
     1491        );
     1492        $user2 = $this->factory->user->create(
     1493            array(
     1494                'user_login' => 'test_json_user2',
     1495                'user_email' => 'testjson2@example.com',
     1496            )
     1497        );
    13571498        $this->allow_user_to_manage_multisite();
    13581499        wp_set_current_user( self::$user );
     
    13661507
    13671508    public function test_update_item_existing_nicename() {
    1368         $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
    1369         $user2 = $this->factory->user->create( array( 'user_login' => 'test_json_user2', 'user_email' => 'testjson2@example.com' ) );
     1509        $user1 = $this->factory->user->create(
     1510            array(
     1511                'user_login' => 'test_json_user',
     1512                'user_email' => 'testjson@example.com',
     1513            )
     1514        );
     1515        $user2 = $this->factory->user->create(
     1516            array(
     1517                'user_login' => 'test_json_user2',
     1518                'user_email' => 'testjson2@example.com',
     1519            )
     1520        );
    13701521        $this->allow_user_to_manage_multisite();
    13711522        wp_set_current_user( self::$user );
     
    13791530
    13801531    public function test_json_update_user() {
    1381         $user_id = $this->factory->user->create( array(
    1382             'user_email' => 'testjson2@example.com',
    1383             'user_pass'  => 'sjflsfl3sdjls',
    1384             'user_login' => 'test_json_update',
    1385             'first_name' => 'Old Name',
    1386             'last_name'  => 'Original Last',
    1387         ));
     1532        $user_id = $this->factory->user->create(
     1533            array(
     1534                'user_email' => 'testjson2@example.com',
     1535                'user_pass'  => 'sjflsfl3sdjls',
     1536                'user_login' => 'test_json_update',
     1537                'first_name' => 'Old Name',
     1538                'last_name'  => 'Original Last',
     1539            )
     1540        );
    13881541        $this->allow_user_to_manage_multisite();
    13891542        wp_set_current_user( self::$user );
     
    13961549        );
    13971550
    1398         $userdata = get_userdata( $user_id );
     1551        $userdata  = get_userdata( $user_id );
    13991552        $pw_before = $userdata->user_pass;
    14001553
     
    16161769     */
    16171770    public function test_update_item_only_roles_as_editor() {
    1618         $user_id = $this->factory->user->create( array(
    1619             'role' => 'author',
    1620         ) );
     1771        $user_id = $this->factory->user->create(
     1772            array(
     1773                'role' => 'author',
     1774            )
     1775        );
    16211776
    16221777        wp_set_current_user( self::$editor );
     
    16311786     */
    16321787    public function test_update_item_only_roles_as_site_administrator() {
    1633         $user_id = $this->factory->user->create( array(
    1634             'role' => 'author',
    1635         ) );
     1788        $user_id = $this->factory->user->create(
     1789            array(
     1790                'role' => 'author',
     1791            )
     1792        );
    16361793
    16371794        wp_set_current_user( self::$user );
     
    16491806     */
    16501807    public function test_update_item_including_roles_and_other_params() {
    1651         $user_id = $this->factory->user->create( array(
    1652             'role' => 'author',
    1653         ) );
     1808        $user_id = $this->factory->user->create(
     1809            array(
     1810                'role' => 'author',
     1811            )
     1812        );
    16541813
    16551814        wp_set_current_user( self::$user );
     
    17051864
    17061865            // Compare expected API output to actual API output
    1707             $this->assertEquals( $expected_output['username']   , $actual_output['username'] );
    1708             $this->assertEquals( $expected_output['name']       , $actual_output['name'] );
    1709             $this->assertEquals( $expected_output['first_name'] , $actual_output['first_name'] );
    1710             $this->assertEquals( $expected_output['last_name']  , $actual_output['last_name'] );
    1711             $this->assertEquals( $expected_output['url']        , $actual_output['url'] );
     1866            $this->assertEquals( $expected_output['username'], $actual_output['username'] );
     1867            $this->assertEquals( $expected_output['name'], $actual_output['name'] );
     1868            $this->assertEquals( $expected_output['first_name'], $actual_output['first_name'] );
     1869            $this->assertEquals( $expected_output['last_name'], $actual_output['last_name'] );
     1870            $this->assertEquals( $expected_output['url'], $actual_output['url'] );
    17121871            $this->assertEquals( $expected_output['description'], $actual_output['description'] );
    1713             $this->assertEquals( $expected_output['nickname']   , $actual_output['nickname'] );
     1872            $this->assertEquals( $expected_output['nickname'], $actual_output['nickname'] );
    17141873
    17151874            // Compare expected API output to WP internal values
    17161875            $user = get_userdata( $actual_output['id'] );
    1717             $this->assertEquals( $expected_output['username']   , $user->user_login );
    1718             $this->assertEquals( $expected_output['name']       , $user->display_name );
    1719             $this->assertEquals( $expected_output['first_name'] , $user->first_name );
    1720             $this->assertEquals( $expected_output['last_name']  , $user->last_name );
    1721             $this->assertEquals( $expected_output['url']        , $user->user_url );
     1876            $this->assertEquals( $expected_output['username'], $user->user_login );
     1877            $this->assertEquals( $expected_output['name'], $user->display_name );
     1878            $this->assertEquals( $expected_output['first_name'], $user->first_name );
     1879            $this->assertEquals( $expected_output['last_name'], $user->last_name );
     1880            $this->assertEquals( $expected_output['url'], $user->user_url );
    17221881            $this->assertEquals( $expected_output['description'], $user->description );
    1723             $this->assertEquals( $expected_output['nickname']   , $user->nickname );
     1882            $this->assertEquals( $expected_output['nickname'], $user->nickname );
    17241883            $this->assertTrue( wp_check_password( addslashes( $expected_output['password'] ), $user->user_pass ) );
    17251884
     
    17421901            $this->assertEquals( $expected_output['username'], $actual_output['username'] );
    17431902        }
    1744         $this->assertEquals( $expected_output['name']       , $actual_output['name'] );
    1745         $this->assertEquals( $expected_output['first_name'] , $actual_output['first_name'] );
    1746         $this->assertEquals( $expected_output['last_name']  , $actual_output['last_name'] );
    1747         $this->assertEquals( $expected_output['url']        , $actual_output['url'] );
     1903        $this->assertEquals( $expected_output['name'], $actual_output['name'] );
     1904        $this->assertEquals( $expected_output['first_name'], $actual_output['first_name'] );
     1905        $this->assertEquals( $expected_output['last_name'], $actual_output['last_name'] );
     1906        $this->assertEquals( $expected_output['url'], $actual_output['url'] );
    17481907        $this->assertEquals( $expected_output['description'], $actual_output['description'] );
    1749         $this->assertEquals( $expected_output['nickname']   , $actual_output['nickname'] );
     1908        $this->assertEquals( $expected_output['nickname'], $actual_output['nickname'] );
    17501909
    17511910        // Compare expected API output to WP internal values
     
    17541913            $this->assertEquals( $expected_output['username'], $user->user_login );
    17551914        }
    1756         $this->assertEquals( $expected_output['name']       , $user->display_name );
    1757         $this->assertEquals( $expected_output['first_name'] , $user->first_name );
    1758         $this->assertEquals( $expected_output['last_name']  , $user->last_name );
    1759         $this->assertEquals( $expected_output['url']        , $user->user_url );
     1915        $this->assertEquals( $expected_output['name'], $user->display_name );
     1916        $this->assertEquals( $expected_output['first_name'], $user->first_name );
     1917        $this->assertEquals( $expected_output['last_name'], $user->last_name );
     1918        $this->assertEquals( $expected_output['url'], $user->user_url );
    17601919        $this->assertEquals( $expected_output['description'], $user->description );
    1761         $this->assertEquals( $expected_output['nickname']   , $user->nickname );
     1920        $this->assertEquals( $expected_output['nickname'], $user->nickname );
    17621921        $this->assertTrue( wp_check_password( addslashes( $expected_output['password'] ), $user->user_pass ) );
    17631922    }
     
    17661925        wp_set_current_user( self::$editor );
    17671926        $this->assertEquals( ! is_multisite(), current_user_can( 'unfiltered_html' ) );
    1768         $this->verify_user_roundtrip( array(
    1769             'id'          => self::$editor,
    1770             'name'        => '\o/ ¯\_(ツ)_/¯',
    1771             'first_name'  => '\o/ ¯\_(ツ)_/¯',
    1772             'last_name'   => '\o/ ¯\_(ツ)_/¯',
    1773             'url'         => '\o/ ¯\_(ツ)_/¯',
    1774             'description' => '\o/ ¯\_(ツ)_/¯',
    1775             'nickname'    => '\o/ ¯\_(ツ)_/¯',
    1776             'password'    => 'o/ ¯_(ツ)_/¯ \'"',
    1777         ), array(
    1778             'name'        => '\o/ ¯\_(ツ)_/¯',
    1779             'first_name'  => '\o/ ¯\_(ツ)_/¯',
    1780             'last_name'   => '\o/ ¯\_(ツ)_/¯',
    1781             'url'         => 'http://o/%20¯_(ツ)_/¯',
    1782             'description' => '\o/ ¯\_(ツ)_/¯',
    1783             'nickname'    => '\o/ ¯\_(ツ)_/¯',
    1784             'password'    => 'o/ ¯_(ツ)_/¯ \'"',
    1785         ) );
     1927        $this->verify_user_roundtrip(
     1928            array(
     1929                'id'          => self::$editor,
     1930                'name'        => '\o/ ¯\_(ツ)_/¯',
     1931                'first_name'  => '\o/ ¯\_(ツ)_/¯',
     1932                'last_name'   => '\o/ ¯\_(ツ)_/¯',
     1933                'url'         => '\o/ ¯\_(ツ)_/¯',
     1934                'description' => '\o/ ¯\_(ツ)_/¯',
     1935                'nickname'    => '\o/ ¯\_(ツ)_/¯',
     1936                'password'    => 'o/ ¯_(ツ)_/¯ \'"',
     1937            ), array(
     1938                'name'        => '\o/ ¯\_(ツ)_/¯',
     1939                'first_name'  => '\o/ ¯\_(ツ)_/¯',
     1940                'last_name'   => '\o/ ¯\_(ツ)_/¯',
     1941                'url'         => 'http://o/%20¯_(ツ)_/¯',
     1942                'description' => '\o/ ¯\_(ツ)_/¯',
     1943                'nickname'    => '\o/ ¯\_(ツ)_/¯',
     1944                'password'    => 'o/ ¯_(ツ)_/¯ \'"',
     1945            )
     1946        );
    17861947    }
    17871948
     
    17901951        if ( is_multisite() ) {
    17911952            $this->assertFalse( current_user_can( 'unfiltered_html' ) );
    1792             $this->verify_user_roundtrip( array(
    1793                 'id'          => self::$editor,
     1953            $this->verify_user_roundtrip(
     1954                array(
     1955                    'id'          => self::$editor,
     1956                    'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1957                    'first_name'  => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1958                    'last_name'   => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1959                    'url'         => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1960                    'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1961                    'nickname'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1962                    'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1963                ), array(
     1964                    'name'        => 'div strong',
     1965                    'first_name'  => 'div strong',
     1966                    'last_name'   => 'div strong',
     1967                    'url'         => 'http://divdiv/div%20strongstrong/strong%20scriptoh%20noes/script',
     1968                    'description' => 'div <strong>strong</strong> oh noes',
     1969                    'nickname'    => 'div strong',
     1970                    'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1971                )
     1972            );
     1973        } else {
     1974            $this->assertTrue( current_user_can( 'unfiltered_html' ) );
     1975            $this->verify_user_roundtrip(
     1976                array(
     1977                    'id'          => self::$editor,
     1978                    'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1979                    'first_name'  => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1980                    'last_name'   => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1981                    'url'         => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1982                    'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1983                    'nickname'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1984                    'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1985                ), array(
     1986                    'name'        => 'div strong',
     1987                    'first_name'  => 'div strong',
     1988                    'last_name'   => 'div strong',
     1989                    'url'         => 'http://divdiv/div%20strongstrong/strong%20scriptoh%20noes/script',
     1990                    'description' => 'div <strong>strong</strong> oh noes',
     1991                    'nickname'    => 'div strong',
     1992                    'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     1993                )
     1994            );
     1995        }
     1996    }
     1997
     1998    public function test_user_roundtrip_as_superadmin() {
     1999        wp_set_current_user( self::$superadmin );
     2000        $this->assertTrue( current_user_can( 'unfiltered_html' ) );
     2001        $valid_username = is_multisite() ? 'noinvalidcharshere' : 'no-invalid-chars-here';
     2002        $this->verify_user_roundtrip(
     2003            array(
     2004                'username'    => $valid_username,
     2005                'name'        => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2006                'first_name'  => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2007                'last_name'   => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2008                'url'         => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2009                'description' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2010                'nickname'    => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2011                'password'    => '& &amp; &invalid; < &lt; &amp;lt;',
     2012            ), array(
     2013                'username'    => $valid_username,
     2014                'name'        => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
     2015                'first_name'  => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
     2016                'last_name'   => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
     2017                'url'         => 'http://&amp;%20&amp;%20&amp;invalid;%20%20&lt;%20&amp;lt;',
     2018                'description' => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
     2019                'nickname'    => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
     2020                'password'    => '& &amp; &invalid; < &lt; &amp;lt;',
     2021            )
     2022        );
     2023    }
     2024
     2025    public function test_user_roundtrip_as_superadmin_html() {
     2026        wp_set_current_user( self::$superadmin );
     2027        $this->assertTrue( current_user_can( 'unfiltered_html' ) );
     2028        $valid_username = is_multisite() ? 'noinvalidcharshere' : 'no-invalid-chars-here';
     2029        $this->verify_user_roundtrip(
     2030            array(
     2031                'username'    => $valid_username,
    17942032                'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    17952033                'first_name'  => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     
    18002038                'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    18012039            ), array(
     2040                'username'    => $valid_username,
    18022041                'name'        => 'div strong',
    18032042                'first_name'  => 'div strong',
     
    18072046                'nickname'    => 'div strong',
    18082047                'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1809             ) );
    1810         } else {
    1811             $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    1812             $this->verify_user_roundtrip( array(
    1813                 'id'          => self::$editor,
    1814                 'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1815                 'first_name'  => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1816                 'last_name'   => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1817                 'url'         => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1818                 'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1819                 'nickname'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1820                 'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1821             ), array(
    1822                 'name'        => 'div strong',
    1823                 'first_name'  => 'div strong',
    1824                 'last_name'   => 'div strong',
    1825                 'url'         => 'http://divdiv/div%20strongstrong/strong%20scriptoh%20noes/script',
    1826                 'description' => 'div <strong>strong</strong> oh noes',
    1827                 'nickname'    => 'div strong',
    1828                 'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1829             ) );
    1830         }
    1831     }
    1832 
    1833     public function test_user_roundtrip_as_superadmin() {
    1834         wp_set_current_user( self::$superadmin );
    1835         $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    1836         $valid_username = is_multisite() ? 'noinvalidcharshere' : 'no-invalid-chars-here';
    1837         $this->verify_user_roundtrip( array(
    1838             'username'    => $valid_username,
    1839             'name'        => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    1840             'first_name'  => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    1841             'last_name'   => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    1842             'url'         => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    1843             'description' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    1844             'nickname'    => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    1845             'password'    => '& &amp; &invalid; < &lt; &amp;lt;',
    1846         ), array(
    1847             'username'    => $valid_username,
    1848             'name'        => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    1849             'first_name'  => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    1850             'last_name'   => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    1851             'url'         => 'http://&amp;%20&amp;%20&amp;invalid;%20%20&lt;%20&amp;lt;',
    1852             'description' => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    1853             'nickname'    => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    1854             'password'    => '& &amp; &invalid; < &lt; &amp;lt;',
    1855         ) );
    1856     }
    1857 
    1858     public function test_user_roundtrip_as_superadmin_html() {
    1859         wp_set_current_user( self::$superadmin );
    1860         $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    1861         $valid_username = is_multisite() ? 'noinvalidcharshere' : 'no-invalid-chars-here';
    1862         $this->verify_user_roundtrip( array(
    1863             'username'    => $valid_username,
    1864             'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1865             'first_name'  => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1866             'last_name'   => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1867             'url'         => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1868             'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1869             'nickname'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1870             'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1871         ), array(
    1872             'username'    => $valid_username,
    1873             'name'        => 'div strong',
    1874             'first_name'  => 'div strong',
    1875             'last_name'   => 'div strong',
    1876             'url'         => 'http://divdiv/div%20strongstrong/strong%20scriptoh%20noes/script',
    1877             'description' => 'div <strong>strong</strong> oh noes',
    1878             'nickname'    => 'div strong',
    1879             'password'    => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    1880         ) );
     2048            )
     2049        );
    18812050    }
    18822051
     
    18882057
    18892058        $userdata = get_userdata( $user_id ); // cache for later
    1890         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2059        $request  = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    18912060        $request->set_param( 'force', true );
    18922061        $request->set_param( 'reassign', false );
     
    19352104
    19362105    public function test_delete_current_item() {
    1937         $user_id = $this->factory->user->create( array( 'role' => 'administrator', 'display_name' => 'Deleted User' ) );
     2106        $user_id = $this->factory->user->create(
     2107            array(
     2108                'role'         => 'administrator',
     2109                'display_name' => 'Deleted User',
     2110            )
     2111        );
    19382112
    19392113        wp_set_current_user( $user_id );
     
    19412115        update_site_option( 'site_admins', array( $user->user_login ) );
    19422116
    1943         $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/me' );
     2117        $request          = new WP_REST_Request( 'DELETE', '/wp/v2/users/me' );
    19442118        $request['force'] = true;
    19452119        $request->set_param( 'reassign', false );
     
    19592133
    19602134    public function test_delete_current_item_no_trash() {
    1961         $user_id = $this->factory->user->create( array( 'role' => 'administrator', 'display_name' => 'Deleted User' ) );
     2135        $user_id = $this->factory->user->create(
     2136            array(
     2137                'role'         => 'administrator',
     2138                'display_name' => 'Deleted User',
     2139            )
     2140        );
    19622141
    19632142        wp_set_current_user( $user_id );
     
    19922171        wp_set_current_user( self::$editor );
    19932172
    1994         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2173        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    19952174        $request['force'] = true;
    19962175        $request->set_param( 'reassign', false );
     
    19992178        $this->assertErrorResponse( 'rest_user_cannot_delete', $response, 403 );
    20002179
    2001         $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/me' );
     2180        $request          = new WP_REST_Request( 'DELETE', '/wp/v2/users/me' );
    20022181        $request['force'] = true;
    20032182        $request->set_param( 'reassign', false );
     
    20112190        wp_set_current_user( self::$user );
    20122191
    2013         $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/100' );
     2192        $request          = new WP_REST_Request( 'DELETE', '/wp/v2/users/100' );
    20142193        $request['force'] = true;
    20152194        $request->set_param( 'reassign', false );
     
    20232202
    20242203        // Test with a new user, to avoid any complications
    2025         $user_id = $this->factory->user->create();
     2204        $user_id     = $this->factory->user->create();
    20262205        $reassign_id = $this->factory->user->create();
    2027         $test_post = $this->factory->post->create(array(
    2028             'post_author' => $user_id,
    2029         ));
     2206        $test_post   = $this->factory->post->create(
     2207            array(
     2208                'post_author' => $user_id,
     2209            )
     2210        );
    20302211
    20312212        // Sanity check to ensure the factory created the post correctly
     
    20352216        // Delete our test user, and reassign to the new author
    20362217        wp_set_current_user( self::$user );
    2037         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2218        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    20382219        $request['force'] = true;
    20392220        $request->set_param( 'reassign', $reassign_id );
     
    20592240        wp_set_current_user( self::$user );
    20602241
    2061         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2242        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    20622243        $request['force'] = true;
    20632244        $request->set_param( 'reassign', 100 );
     
    20792260        wp_set_current_user( self::$user );
    20802261
    2081         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2262        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    20822263        $request['force'] = true;
    20832264        $request->set_param( 'reassign', 'null' );
     
    20932274        wp_set_current_user( self::$user );
    20942275
    2095         $test_post = $this->factory->post->create(array(
    2096             'post_author' => $user_id,
    2097         ));
    2098 
    2099         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2276        $test_post = $this->factory->post->create(
     2277            array(
     2278                'post_author' => $user_id,
     2279            )
     2280        );
     2281
     2282        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    21002283        $request['force'] = true;
    21012284        $request->set_param( 'reassign', false );
     
    21182301        wp_set_current_user( self::$user );
    21192302
    2120         $test_post = $this->factory->post->create(array(
    2121             'post_author' => $user_id,
    2122         ));
    2123 
    2124         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2303        $test_post = $this->factory->post->create(
     2304            array(
     2305                'post_author' => $user_id,
     2306            )
     2307        );
     2308
     2309        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    21252310        $request['force'] = true;
    21262311        $request->set_param( 'reassign', 'false' );
     
    21432328        wp_set_current_user( self::$user );
    21442329
    2145         $test_post = $this->factory->post->create(array(
    2146             'post_author' => $user_id,
    2147         ));
    2148 
    2149         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2330        $test_post = $this->factory->post->create(
     2331            array(
     2332                'post_author' => $user_id,
     2333            )
     2334        );
     2335
     2336        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    21502337        $request['force'] = true;
    21512338        $request->set_param( 'reassign', '' );
     
    21682355        wp_set_current_user( self::$user );
    21692356
    2170         $test_post = $this->factory->post->create(array(
    2171             'post_author' => $user_id,
    2172         ));
    2173 
    2174         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
     2357        $test_post = $this->factory->post->create(
     2358            array(
     2359                'post_author' => $user_id,
     2360            )
     2361        );
     2362
     2363        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
    21752364        $request['force'] = true;
    21762365        $request->set_param( 'reassign', 0 );
     
    21882377
    21892378    public function test_get_item_schema() {
    2190         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
    2191         $response = $this->server->dispatch( $request );
    2192         $data = $response->get_data();
     2379        $request    = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
     2380        $response   = $this->server->dispatch( $request );
     2381        $data       = $response->get_data();
    21932382        $properties = $data['schema']['properties'];
    21942383
     
    22182407    public function test_get_item_schema_show_avatar() {
    22192408        update_option( 'show_avatars', false );
    2220         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
    2221         $response = $this->server->dispatch( $request );
    2222         $data = $response->get_data();
     2409        $request    = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
     2410        $response   = $this->server->dispatch( $request );
     2411        $data       = $response->get_data();
    22232412        $properties = $data['schema']['properties'];
    22242413
     
    22352424        );
    22362425
    2237         register_rest_field( 'user', 'my_custom_int', array(
    2238             'schema'          => $schema,
    2239             'get_callback'    => array( $this, 'additional_field_get_callback' ),
    2240             'update_callback' => array( $this, 'additional_field_update_callback' ),
    2241         ) );
     2426        register_rest_field(
     2427            'user', 'my_custom_int', array(
     2428                'schema'          => $schema,
     2429                'get_callback'    => array( $this, 'additional_field_get_callback' ),
     2430                'update_callback' => array( $this, 'additional_field_update_callback' ),
     2431            )
     2432        );
    22422433
    22432434        $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
    22442435
    22452436        $response = $this->server->dispatch( $request );
    2246         $data = $response->get_data();
     2437        $data     = $response->get_data();
    22472438
    22482439        $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] );
     
    22612452
    22622453        $request = new WP_REST_Request( 'POST', '/wp/v2/users/1' );
    2263         $request->set_body_params(array(
    2264             'my_custom_int' => 123,
    2265         ));
     2454        $request->set_body_params(
     2455            array(
     2456                'my_custom_int' => 123,
     2457            )
     2458        );
    22662459
    22672460        $response = $this->server->dispatch( $request );
     
    22692462
    22702463        $request = new WP_REST_Request( 'POST', '/wp/v2/users' );
    2271         $request->set_body_params(array(
    2272             'my_custom_int' => 123,
    2273             'email' => 'joe@foobar.com',
    2274             'username' => 'abc123',
    2275             'password' => 'hello',
    2276         ));
     2464        $request->set_body_params(
     2465            array(
     2466                'my_custom_int' => 123,
     2467                'email'         => 'joe@foobar.com',
     2468                'username'      => 'abc123',
     2469                'password'      => 'hello',
     2470            )
     2471        );
    22772472
    22782473        $response = $this->server->dispatch( $request );
     
    22922487        );
    22932488
    2294         register_rest_field( 'user', 'my_custom_int', array(
    2295             'schema'          => $schema,
    2296             'get_callback'    => array( $this, 'additional_field_get_callback' ),
    2297             'update_callback' => array( $this, 'additional_field_update_callback' ),
    2298         ) );
     2489        register_rest_field(
     2490            'user', 'my_custom_int', array(
     2491                'schema'          => $schema,
     2492                'get_callback'    => array( $this, 'additional_field_get_callback' ),
     2493                'update_callback' => array( $this, 'additional_field_update_callback' ),
     2494            )
     2495        );
    22992496
    23002497        wp_set_current_user( 1 );
     
    23062503        // Check for error on update.
    23072504        $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/users/%d', self::$user ) );
    2308         $request->set_body_params( array(
    2309             'my_custom_int' => 'returnError',
    2310         ) );
     2505        $request->set_body_params(
     2506            array(
     2507                'my_custom_int' => 'returnError',
     2508            )
     2509        );
    23112510
    23122511        $response = $this->server->dispatch( $request );
     
    23242523    public function test_get_item_from_different_site_as_site_administrator() {
    23252524        switch_to_blog( self::$site );
    2326         $user_id = $this->factory->user->create( array(
    2327             'role' => 'author',
    2328         ) );
     2525        $user_id = $this->factory->user->create(
     2526            array(
     2527                'role' => 'author',
     2528            )
     2529        );
    23292530        restore_current_blog();
    23302531
     
    23422543    public function test_get_item_from_different_site_as_network_administrator() {
    23432544        switch_to_blog( self::$site );
    2344         $user_id = $this->factory->user->create( array(
    2345             'role' => 'author',
    2346         ) );
     2545        $user_id = $this->factory->user->create(
     2546            array(
     2547                'role' => 'author',
     2548            )
     2549        );
    23472550        restore_current_blog();
    23482551
     
    23602563    public function test_update_item_from_different_site_as_site_administrator() {
    23612564        switch_to_blog( self::$site );
    2362         $user_id = $this->factory->user->create( array(
    2363             'role' => 'author',
    2364         ) );
     2565        $user_id = $this->factory->user->create(
     2566            array(
     2567                'role' => 'author',
     2568            )
     2569        );
    23652570        restore_current_blog();
    23662571
     
    23802585    public function test_update_item_from_different_site_as_network_administrator() {
    23812586        switch_to_blog( self::$site );
    2382         $user_id = $this->factory->user->create( array(
    2383             'role' => 'author',
    2384         ) );
     2587        $user_id = $this->factory->user->create(
     2588            array(
     2589                'role' => 'author',
     2590            )
     2591        );
    23852592        restore_current_blog();
    23862593
     
    24002607    public function test_delete_item_from_different_site_as_site_administrator() {
    24012608        switch_to_blog( self::$site );
    2402         $user_id = $this->factory->user->create( array(
    2403             'role' => 'author',
    2404         ) );
     2609        $user_id = $this->factory->user->create(
     2610            array(
     2611                'role' => 'author',
     2612            )
     2613        );
    24052614        restore_current_blog();
    24062615
     
    24202629    public function test_delete_item_from_different_site_as_network_administrator() {
    24212630        switch_to_blog( self::$site );
    2422         $user_id = $this->factory->user->create( array(
    2423             'role' => 'author',
    2424         ) );
     2631        $user_id = $this->factory->user->create(
     2632            array(
     2633                'role' => 'author',
     2634            )
     2635        );
    24252636        restore_current_blog();
    24262637
     
    24842695        }
    24852696
    2486         $this->assertEqualSets( array(
    2487             'self',
    2488             'collection',
    2489         ), array_keys( $links ) );
     2697        $this->assertEqualSets(
     2698            array(
     2699                'self',
     2700                'collection',
     2701            ), array_keys( $links )
     2702        );
    24902703
    24912704        $this->assertArrayNotHasKey( 'password', $data );
     
    24952708        $this->assertEquals( 200, $response->get_status() );
    24962709
    2497         $data = $response->get_data();
     2710        $data     = $response->get_data();
    24982711        $userdata = get_userdata( $data['id'] );
    24992712        $this->check_user_data( $userdata, $data, $context, $response->get_links() );
     
    25072720        }
    25082721
    2509         $data = $response->get_data();
     2722        $data     = $response->get_data();
    25102723        $userdata = get_userdata( $data['id'] );
    25112724        $this->check_user_data( $userdata, $data, 'edit', $response->get_links() );
Note: See TracChangeset for help on using the changeset viewer.