Make WordPress Core


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

    r40101 r42343  
    2828
    2929    public static function wpSetUpBeforeClass( $factory ) {
    30         self::$superadmin_id = $factory->user->create( array(
    31             'role'       => 'administrator',
    32             'user_login' => 'superadmin',
    33         ) );
    34         self::$admin_id = $factory->user->create( array(
    35             'role' => 'administrator',
    36         ) );
    37         self::$editor_id = $factory->user->create( array(
    38             'role' => 'editor',
    39         ) );
    40         self::$subscriber_id = $factory->user->create( array(
    41             'role' => 'subscriber',
    42         ) );
    43         self::$author_id = $factory->user->create( array(
    44             'role'         => 'author',
    45             'display_name' => 'Sea Captain',
    46             'first_name'   => 'Horatio',
    47             'last_name'    => 'McCallister',
    48             'user_email'   => 'captain@thefryingdutchman.com',
    49             'user_url'     => 'http://thefryingdutchman.com',
    50         ) );
    51 
    52         self::$post_id = $factory->post->create();
    53         self::$private_id = $factory->post->create( array(
    54             'post_status' => 'private',
    55         ) );
    56         self::$password_id = $factory->post->create( array(
    57             'post_password'    => 'toomanysecrets',
    58         ) );
    59         self::$draft_id = $factory->post->create( array(
    60             'post_status' => 'draft',
    61         ) );
    62         self::$trash_id = $factory->post->create( array(
    63             'post_status' => 'trash',
    64         ) );
    65 
    66         self::$approved_id = $factory->comment->create( array(
    67             'comment_approved' => 1,
    68             'comment_post_ID'  => self::$post_id,
    69             'user_id'          => 0,
    70         ) );
    71         self::$hold_id = $factory->comment->create( array(
    72             'comment_approved' => 0,
    73             'comment_post_ID'  => self::$post_id,
    74             'user_id'          => self::$subscriber_id,
    75         ) );
     30        self::$superadmin_id = $factory->user->create(
     31            array(
     32                'role'       => 'administrator',
     33                'user_login' => 'superadmin',
     34            )
     35        );
     36        self::$admin_id      = $factory->user->create(
     37            array(
     38                'role' => 'administrator',
     39            )
     40        );
     41        self::$editor_id     = $factory->user->create(
     42            array(
     43                'role' => 'editor',
     44            )
     45        );
     46        self::$subscriber_id = $factory->user->create(
     47            array(
     48                'role' => 'subscriber',
     49            )
     50        );
     51        self::$author_id     = $factory->user->create(
     52            array(
     53                'role'         => 'author',
     54                'display_name' => 'Sea Captain',
     55                'first_name'   => 'Horatio',
     56                'last_name'    => 'McCallister',
     57                'user_email'   => 'captain@thefryingdutchman.com',
     58                'user_url'     => 'http://thefryingdutchman.com',
     59            )
     60        );
     61
     62        self::$post_id     = $factory->post->create();
     63        self::$private_id  = $factory->post->create(
     64            array(
     65                'post_status' => 'private',
     66            )
     67        );
     68        self::$password_id = $factory->post->create(
     69            array(
     70                'post_password' => 'toomanysecrets',
     71            )
     72        );
     73        self::$draft_id    = $factory->post->create(
     74            array(
     75                'post_status' => 'draft',
     76            )
     77        );
     78        self::$trash_id    = $factory->post->create(
     79            array(
     80                'post_status' => 'trash',
     81            )
     82        );
     83
     84        self::$approved_id = $factory->comment->create(
     85            array(
     86                'comment_approved' => 1,
     87                'comment_post_ID'  => self::$post_id,
     88                'user_id'          => 0,
     89            )
     90        );
     91        self::$hold_id     = $factory->comment->create(
     92            array(
     93                'comment_approved' => 0,
     94                'comment_post_ID'  => self::$post_id,
     95                'user_id'          => self::$subscriber_id,
     96            )
     97        );
    7698    }
    7799
     
    111133    public function test_context_param() {
    112134        // Collection
    113         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
    114         $response = $this->server->dispatch( $request );
    115         $data = $response->get_data();
     135        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
     136        $response = $this->server->dispatch( $request );
     137        $data     = $response->get_data();
    116138        $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
    117139        $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    118140        // Single
    119         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id );
    120         $response = $this->server->dispatch( $request );
    121         $data = $response->get_data();
     141        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id );
     142        $response = $this->server->dispatch( $request );
     143        $data     = $response->get_data();
    122144        $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
    123145        $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
     
    125147
    126148    public function test_registered_query_params() {
    127         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
    128         $response = $this->server->dispatch( $request );
    129         $data = $response->get_data();
    130         $keys = array_keys( $data['endpoints'][0]['args'] );
     149        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
     150        $response = $this->server->dispatch( $request );
     151        $data     = $response->get_data();
     152        $keys     = array_keys( $data['endpoints'][0]['args'] );
    131153        sort( $keys );
    132         $this->assertEquals( array(
    133             'after',
    134             'author',
    135             'author_email',
    136             'author_exclude',
    137             'before',
    138             'context',
    139             'exclude',
    140             'include',
    141             'offset',
    142             'order',
    143             'orderby',
    144             'page',
    145             'parent',
    146             'parent_exclude',
    147             'password',
    148             'per_page',
    149             'post',
    150             'search',
    151             'status',
    152             'type',
    153             ), $keys );
     154        $this->assertEquals(
     155            array(
     156                'after',
     157                'author',
     158                'author_email',
     159                'author_exclude',
     160                'before',
     161                'context',
     162                'exclude',
     163                'include',
     164                'offset',
     165                'order',
     166                'orderby',
     167                'page',
     168                'parent',
     169                'parent_exclude',
     170                'password',
     171                'per_page',
     172                'post',
     173                'search',
     174                'status',
     175                'type',
     176            ), $keys
     177        );
    154178    }
    155179
     
    173197        wp_set_current_user( 0 );
    174198
    175         $args = array(
     199        $args             = array(
    176200            'comment_approved' => 1,
    177201            'comment_post_ID'  => self::$password_id,
     
    195219    public function test_get_items_with_password_without_post() {
    196220        wp_set_current_user( 0 );
    197         $args = array(
     221        $args             = array(
    198222            'comment_approved' => 1,
    199223            'comment_post_ID'  => self::$password_id,
     
    216240    public function test_get_items_with_password_with_multiple_post() {
    217241        wp_set_current_user( 0 );
    218         $args = array(
     242        $args             = array(
    219243            'comment_approved' => 1,
    220244            'comment_post_ID'  => self::$password_id,
     
    233257        wp_set_current_user( 0 );
    234258
    235         $args = array(
     259        $args             = array(
    236260            'comment_approved' => 1,
    237261            'comment_post_ID'  => self::$password_id,
     
    251275        wp_set_current_user( self::$admin_id );
    252276
    253         $args = array(
     277        $args             = array(
    254278            'comment_approved' => 1,
    255279            'comment_post_ID'  => self::$password_id,
     
    269293        wp_set_current_user( 0 );
    270294
    271         $args = array(
     295        $args            = array(
    272296            'comment_approved' => 1,
    273297            'comment_post_ID'  => self::$private_id,
     
    287311        wp_set_current_user( self::$admin_id );
    288312
    289         $args = array(
     313        $args            = array(
    290314            'comment_approved' => 1,
    291315            'comment_post_ID'  => self::$private_id,
     
    305329        wp_set_current_user( 0 );
    306330
    307         $comment_id = $this->factory->comment->create( array(
    308             'comment_approved' => 1,
    309             'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
    310         ));
     331        $comment_id = $this->factory->comment->create(
     332            array(
     333                'comment_approved' => 1,
     334                'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
     335            )
     336        );
    311337
    312338        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    324350        wp_set_current_user( self::$admin_id );
    325351
    326         $comment_id = $this->factory->comment->create( array(
    327             'comment_approved' => 1,
    328             'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
    329         ));
     352        $comment_id = $this->factory->comment->create(
     353            array(
     354                'comment_approved' => 1,
     355                'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
     356            )
     357        );
    330358
    331359        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    380408
    381409        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    382         $request->set_query_params( array(
    383             'post' => $second_post_id,
    384         ) );
     410        $request->set_query_params(
     411            array(
     412                'post' => $second_post_id,
     413            )
     414        );
    385415
    386416        $response = $this->server->dispatch( $request );
     
    397427            'comment_post_ID'  => self::$post_id,
    398428        );
    399         $id1 = $this->factory->comment->create( $args );
     429        $id1  = $this->factory->comment->create( $args );
    400430        $this->factory->comment->create( $args );
    401         $id3 = $this->factory->comment->create( $args );
     431        $id3     = $this->factory->comment->create( $args );
    402432        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    403433        // Order=>asc
     
    405435        $request->set_param( 'include', array( $id3, $id1 ) );
    406436        $response = $this->server->dispatch( $request );
    407         $data = $response->get_data();
     437        $data     = $response->get_data();
    408438        $this->assertEquals( 2, count( $data ) );
    409439        $this->assertEquals( $id1, $data[0]['id'] );
     
    411441        $request->set_param( 'orderby', 'include' );
    412442        $response = $this->server->dispatch( $request );
    413         $data = $response->get_data();
     443        $data     = $response->get_data();
    414444        $this->assertEquals( 2, count( $data ) );
    415445        $this->assertEquals( $id3, $data[0]['id'] );
     
    427457    public function test_get_items_exclude_query() {
    428458        wp_set_current_user( self::$admin_id );
    429         $args = array(
     459        $args     = array(
    430460            'comment_approved' => 1,
    431461            'comment_post_ID'  => self::$post_id,
    432462        );
    433         $id1 = $this->factory->comment->create( $args );
    434         $id2 = $this->factory->comment->create( $args );
    435         $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    436         $response = $this->server->dispatch( $request );
    437         $data = $response->get_data();
     463        $id1      = $this->factory->comment->create( $args );
     464        $id2      = $this->factory->comment->create( $args );
     465        $request  = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     466        $response = $this->server->dispatch( $request );
     467        $data     = $response->get_data();
    438468        $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    439469        $this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
    440470        $request->set_param( 'exclude', array( $id2 ) );
    441471        $response = $this->server->dispatch( $request );
    442         $data = $response->get_data();
     472        $data     = $response->get_data();
    443473        $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    444474        $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
     
    485515        $this->factory->comment->create( $args );
    486516        $this->factory->comment->create( $args );
    487         $id3 = $this->factory->comment->create( $args );
     517        $id3     = $this->factory->comment->create( $args );
    488518        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    489519        // order defaults to 'desc'
    490520        $response = $this->server->dispatch( $request );
    491         $data = $response->get_data();
     521        $data     = $response->get_data();
    492522        $this->assertEquals( $id3, $data[0]['id'] );
    493523        // order=>asc
    494524        $request->set_param( 'order', 'asc' );
    495525        $response = $this->server->dispatch( $request );
    496         $data = $response->get_data();
     526        $data     = $response->get_data();
    497527        $this->assertEquals( self::$approved_id, $data[0]['id'] );
    498528        // order=>asc,id should fail
     
    563593        $this->factory->comment->create( $args );
    564594
    565         $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     595        $request  = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    566596        $response = $this->server->dispatch( $request );
    567597        $comments = $response->get_data();
     
    595625
    596626    public function test_get_items_parent_arg() {
    597         $args = array(
    598             'comment_approved'  => 1,
    599             'comment_post_ID'   => self::$post_id,
    600         );
    601         $parent_id = $this->factory->comment->create( $args );
    602         $parent_id2 = $this->factory->comment->create( $args );
     627        $args                   = array(
     628            'comment_approved' => 1,
     629            'comment_post_ID'  => self::$post_id,
     630        );
     631        $parent_id              = $this->factory->comment->create( $args );
     632        $parent_id2             = $this->factory->comment->create( $args );
    603633        $args['comment_parent'] = $parent_id;
    604634        $this->factory->comment->create( $args );
     
    606636        $this->factory->comment->create( $args );
    607637        // All comments in the database
    608         $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     638        $request  = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    609639        $response = $this->server->dispatch( $request );
    610640        $this->assertCount( 5, $response->get_data() );
     
    624654
    625655    public function test_get_items_parent_exclude_arg() {
    626         $args = array(
    627             'comment_approved'  => 1,
    628             'comment_post_ID'   => self::$post_id,
    629         );
    630         $parent_id = $this->factory->comment->create( $args );
    631         $parent_id2 = $this->factory->comment->create( $args );
     656        $args                   = array(
     657            'comment_approved' => 1,
     658            'comment_post_ID'  => self::$post_id,
     659        );
     660        $parent_id              = $this->factory->comment->create( $args );
     661        $parent_id2             = $this->factory->comment->create( $args );
    632662        $args['comment_parent'] = $parent_id;
    633663        $this->factory->comment->create( $args );
     
    635665        $this->factory->comment->create( $args );
    636666        // All comments in the database
    637         $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     667        $request  = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    638668        $response = $this->server->dispatch( $request );
    639669        $this->assertCount( 5, $response->get_data() );
     
    654684    public function test_get_items_search_query() {
    655685        wp_set_current_user( self::$admin_id );
    656         $args = array(
     686        $args                    = array(
    657687            'comment_approved' => 1,
    658688            'comment_post_ID'  => self::$post_id,
     
    660690            'comment_author'   => 'Homer J Simpson',
    661691        );
    662         $id1 = $this->factory->comment->create( $args );
     692        $id1                     = $this->factory->comment->create( $args );
    663693        $args['comment_content'] = 'bar';
    664694        $this->factory->comment->create( $args );
     
    666696        $this->factory->comment->create( $args );
    667697        // 3 comments, plus 1 created in construct
    668         $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     698        $request  = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    669699        $response = $this->server->dispatch( $request );
    670700        $this->assertCount( 4, $response->get_data() );
     
    672702        $request->set_param( 'search', 'foo' );
    673703        $response = $this->server->dispatch( $request );
    674         $data = $response->get_data();
     704        $data     = $response->get_data();
    675705        $this->assertCount( 1, $data );
    676706        $this->assertEquals( $id1, $data[0]['id'] );
     
    681711        // Start of the index
    682712        for ( $i = 0; $i < 49; $i++ ) {
    683             $this->factory->comment->create( array(
    684                 'comment_content'   => "Comment {$i}",
    685                 'comment_post_ID'   => self::$post_id,
    686                 ) );
     713            $this->factory->comment->create(
     714                array(
     715                    'comment_content' => "Comment {$i}",
     716                    'comment_post_ID' => self::$post_id,
     717                )
     718            );
    687719        }
    688         $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    689         $response = $this->server->dispatch( $request );
    690         $headers = $response->get_headers();
     720        $request  = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     721        $response = $this->server->dispatch( $request );
     722        $headers  = $response->get_headers();
    691723        $this->assertEquals( 50, $headers['X-WP-Total'] );
    692724        $this->assertEquals( 5, $headers['X-WP-TotalPages'] );
    693         $next_link = add_query_arg( array(
    694             'page'    => 2,
    695             ), rest_url( '/wp/v2/comments' ) );
     725        $next_link = add_query_arg(
     726            array(
     727                'page' => 2,
     728            ), rest_url( '/wp/v2/comments' )
     729        );
    696730        $this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) );
    697731        $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
    698732        // 3rd page
    699         $this->factory->comment->create( array(
    700                 'comment_content'   => 'Comment 51',
    701                 'comment_post_ID'   => self::$post_id,
    702                 ) );
     733        $this->factory->comment->create(
     734            array(
     735                'comment_content' => 'Comment 51',
     736                'comment_post_ID' => self::$post_id,
     737            )
     738        );
    703739        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
    704740        $request->set_param( 'page', 3 );
    705741        $response = $this->server->dispatch( $request );
    706         $headers = $response->get_headers();
     742        $headers  = $response->get_headers();
    707743        $this->assertEquals( 51, $headers['X-WP-Total'] );
    708744        $this->assertEquals( 6, $headers['X-WP-TotalPages'] );
    709         $prev_link = add_query_arg( array(
    710             'page'    => 2,
    711             ), rest_url( '/wp/v2/comments' ) );
     745        $prev_link = add_query_arg(
     746            array(
     747                'page' => 2,
     748            ), rest_url( '/wp/v2/comments' )
     749        );
    712750        $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    713         $next_link = add_query_arg( array(
    714             'page'    => 4,
    715             ), rest_url( '/wp/v2/comments' ) );
     751        $next_link = add_query_arg(
     752            array(
     753                'page' => 4,
     754            ), rest_url( '/wp/v2/comments' )
     755        );
    716756        $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
    717757        // Last page
     
    719759        $request->set_param( 'page', 6 );
    720760        $response = $this->server->dispatch( $request );
    721         $headers = $response->get_headers();
     761        $headers  = $response->get_headers();
    722762        $this->assertEquals( 51, $headers['X-WP-Total'] );
    723763        $this->assertEquals( 6, $headers['X-WP-TotalPages'] );
    724         $prev_link = add_query_arg( array(
    725             'page'    => 5,
    726             ), rest_url( '/wp/v2/comments' ) );
     764        $prev_link = add_query_arg(
     765            array(
     766                'page' => 5,
     767            ), rest_url( '/wp/v2/comments' )
     768        );
    727769        $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    728770        $this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
     
    731773        $request->set_param( 'page', 8 );
    732774        $response = $this->server->dispatch( $request );
    733         $headers = $response->get_headers();
     775        $headers  = $response->get_headers();
    734776        $this->assertEquals( 51, $headers['X-WP-Total'] );
    735777        $this->assertEquals( 6, $headers['X-WP-TotalPages'] );
    736         $prev_link = add_query_arg( array(
    737             'page'    => 6,
    738             ), rest_url( '/wp/v2/comments' ) );
     778        $prev_link = add_query_arg(
     779            array(
     780                'page' => 6,
     781            ), rest_url( '/wp/v2/comments' )
     782        );
    739783        $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    740784        $this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
     
    750794
    751795    public function test_get_comments_valid_date() {
    752         $comment1 = $this->factory->comment->create( array(
    753             'comment_date'    => '2016-01-15T00:00:00Z',
    754             'comment_post_ID' => self::$post_id,
    755         ) );
    756         $comment2 = $this->factory->comment->create( array(
    757             'comment_date'    => '2016-01-16T00:00:00Z',
    758             'comment_post_ID' => self::$post_id,
    759         ) );
    760         $comment3 = $this->factory->comment->create( array(
    761             'comment_date'    => '2016-01-17T00:00:00Z',
    762             'comment_post_ID' => self::$post_id,
    763         ) );
     796        $comment1 = $this->factory->comment->create(
     797            array(
     798                'comment_date'    => '2016-01-15T00:00:00Z',
     799                'comment_post_ID' => self::$post_id,
     800            )
     801        );
     802        $comment2 = $this->factory->comment->create(
     803            array(
     804                'comment_date'    => '2016-01-16T00:00:00Z',
     805                'comment_post_ID' => self::$post_id,
     806            )
     807        );
     808        $comment3 = $this->factory->comment->create(
     809            array(
     810                'comment_date'    => '2016-01-17T00:00:00Z',
     811                'comment_post_ID' => self::$post_id,
     812            )
     813        );
    764814
    765815        $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     
    767817        $request->set_param( 'before', '2016-01-17T00:00:00Z' );
    768818        $response = $this->server->dispatch( $request );
    769         $data = $response->get_data();
     819        $data     = $response->get_data();
    770820        $this->assertCount( 1, $data );
    771821        $this->assertEquals( $comment2, $data[0]['id'] );
     
    785835        wp_set_current_user( self::$admin_id );
    786836        $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    787         $request->set_query_params( array(
    788             'context' => 'edit',
    789         ) );
     837        $request->set_query_params(
     838            array(
     839                'context' => 'edit',
     840            )
     841        );
    790842
    791843        $response = $this->server->dispatch( $request );
     
    802854
    803855        $data = $response->get_data();
    804         $this->assertArrayHasKey( 24,  $data['author_avatar_urls'] );
    805         $this->assertArrayHasKey( 48,  $data['author_avatar_urls'] );
    806         $this->assertArrayHasKey( 96,  $data['author_avatar_urls'] );
     856        $this->assertArrayHasKey( 24, $data['author_avatar_urls'] );
     857        $this->assertArrayHasKey( 48, $data['author_avatar_urls'] );
     858        $this->assertArrayHasKey( 96, $data['author_avatar_urls'] );
    807859
    808860        $comment = get_comment( self::$approved_id );
     
    831883    public function test_get_comment_invalid_post_id() {
    832884        wp_set_current_user( 0 );
    833         $comment_id = $this->factory->comment->create( array(
    834             'comment_approved' => 1,
    835             'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
    836         ));
    837         $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id );
     885        $comment_id = $this->factory->comment->create(
     886            array(
     887                'comment_approved' => 1,
     888                'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
     889            )
     890        );
     891        $request    = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id );
    838892
    839893        $response = $this->server->dispatch( $request );
     
    843897    public function test_get_comment_invalid_post_id_as_admin() {
    844898        wp_set_current_user( self::$admin_id );
    845         $comment_id = $this->factory->comment->create( array(
    846             'comment_approved' => 1,
    847             'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
    848         ));
    849         $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id );
     899        $comment_id = $this->factory->comment->create(
     900            array(
     901                'comment_approved' => 1,
     902                'comment_post_ID'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
     903            )
     904        );
     905        $request    = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id );
    850906
    851907        $response = $this->server->dispatch( $request );
     
    872928
    873929    public function test_get_comment_with_children_link() {
    874         $comment_id_1 = $this->factory->comment->create( array(
    875             'comment_approved' => 1,
    876             'comment_post_ID'  => self::$post_id,
    877             'user_id'          => self::$subscriber_id,
    878         ) );
    879 
    880         $child_comment = $this->factory->comment->create( array(
    881             'comment_approved' => 1,
    882             'comment_parent'   => $comment_id_1,
    883             'comment_post_ID'  => self::$post_id,
    884             'user_id'          => self::$subscriber_id,
    885         ) );
    886 
    887         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
     930        $comment_id_1 = $this->factory->comment->create(
     931            array(
     932                'comment_approved' => 1,
     933                'comment_post_ID'  => self::$post_id,
     934                'user_id'          => self::$subscriber_id,
     935            )
     936        );
     937
     938        $child_comment = $this->factory->comment->create(
     939            array(
     940                'comment_approved' => 1,
     941                'comment_parent'   => $comment_id_1,
     942                'comment_post_ID'  => self::$post_id,
     943                'user_id'          => self::$subscriber_id,
     944            )
     945        );
     946
     947        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
    888948        $response = $this->server->dispatch( $request );
    889949        $this->assertEquals( 200, $response->get_status() );
     
    892952
    893953    public function test_get_comment_without_children_link() {
    894         $comment_id_1 = $this->factory->comment->create( array(
    895             'comment_approved' => 1,
    896             'comment_post_ID'  => self::$post_id,
    897             'user_id'          => self::$subscriber_id,
    898         ) );
    899 
    900         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
     954        $comment_id_1 = $this->factory->comment->create(
     955            array(
     956                'comment_approved' => 1,
     957                'comment_post_ID'  => self::$post_id,
     958                'user_id'          => self::$subscriber_id,
     959            )
     960        );
     961
     962        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
    901963        $response = $this->server->dispatch( $request );
    902964        $this->assertEquals( 200, $response->get_status() );
     
    906968    public function test_get_comment_with_password_without_edit_post_permission() {
    907969        wp_set_current_user( self::$subscriber_id );
    908         $args = array(
     970        $args             = array(
    909971            'comment_approved' => 1,
    910972            'comment_post_ID'  => self::$password_id,
    911973        );
    912974        $password_comment = $this->factory->comment->create( $args );
    913         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) );
    914         $response = $this->server->dispatch( $request );
     975        $request          = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) );
     976        $response         = $this->server->dispatch( $request );
    915977        $this->assertErrorResponse( 'rest_cannot_read', $response, 403 );
    916978    }
     
    922984        wp_set_current_user( self::$subscriber_id );
    923985
    924         $args = array(
     986        $args             = array(
    925987            'comment_approved' => 1,
    926988            'comment_post_ID'  => self::$password_id,
     
    9391001
    9401002        $params = array(
    941             'post'    => self::$post_id,
     1003            'post'         => self::$post_id,
    9421004            'author_name'  => 'Comic Book Guy',
    9431005            'author_email' => 'cbg@androidsdungeon.com',
    9441006            'author_url'   => 'http://androidsdungeon.com',
    945             'content' => 'Worst Comment Ever!',
    946             'date'    => '2014-11-07T10:14:25',
     1007            'content'      => 'Worst Comment Ever!',
     1008            'date'         => '2014-11-07T10:14:25',
    9471009        );
    9481010
     
    9631025    public function comment_dates_provider() {
    9641026        return array(
    965             'set date without timezone' => array(
    966                 'params'   => array(
     1027            'set date without timezone'     => array(
     1028                'params'  => array(
    9671029                    'timezone_string' => 'America/New_York',
    9681030                    'date'            => '2016-12-12T14:00:00',
    9691031                ),
    9701032                'results' => array(
    971                     'date'            => '2016-12-12T14:00:00',
    972                     'date_gmt'        => '2016-12-12T19:00:00',
     1033                    'date'     => '2016-12-12T14:00:00',
     1034                    'date_gmt' => '2016-12-12T19:00:00',
    9731035                ),
    9741036            ),
    9751037            'set date_gmt without timezone' => array(
    976                 'params'   => array(
     1038                'params'  => array(
    9771039                    'timezone_string' => 'America/New_York',
    9781040                    'date_gmt'        => '2016-12-12T19:00:00',
    9791041                ),
    9801042                'results' => array(
    981                     'date'            => '2016-12-12T14:00:00',
    982                     'date_gmt'        => '2016-12-12T19:00:00',
     1043                    'date'     => '2016-12-12T14:00:00',
     1044                    'date_gmt' => '2016-12-12T19:00:00',
    9831045                ),
    9841046            ),
    985             'set date with timezone' => array(
    986                 'params'   => array(
     1047            'set date with timezone'        => array(
     1048                'params'  => array(
    9871049                    'timezone_string' => 'America/New_York',
    9881050                    'date'            => '2016-12-12T18:00:00-01:00',
    9891051                ),
    9901052                'results' => array(
    991                     'date'            => '2016-12-12T14:00:00',
    992                     'date_gmt'        => '2016-12-12T19:00:00',
     1053                    'date'     => '2016-12-12T14:00:00',
     1054                    'date_gmt' => '2016-12-12T19:00:00',
    9931055                ),
    9941056            ),
    995             'set date_gmt with timezone' => array(
    996                 'params'   => array(
     1057            'set date_gmt with timezone'    => array(
     1058                'params'  => array(
    9971059                    'timezone_string' => 'America/New_York',
    9981060                    'date_gmt'        => '2016-12-12T18:00:00-01:00',
    9991061                ),
    10001062                'results' => array(
    1001                     'date'            => '2016-12-12T14:00:00',
    1002                     'date_gmt'        => '2016-12-12T19:00:00',
     1063                    'date'     => '2016-12-12T14:00:00',
     1064                    'date_gmt' => '2016-12-12T19:00:00',
    10031065                ),
    10041066            ),
     
    10271089
    10281090        $this->assertEquals( 201, $response->get_status() );
    1029         $data = $response->get_data();
     1091        $data    = $response->get_data();
    10301092        $comment = get_comment( $data['id'] );
    10311093
     
    10591121        $this->assertEquals( 201, $response->get_status() );
    10601122
    1061         $data = $response->get_data();
     1123        $data        = $response->get_data();
    10621124        $new_comment = get_comment( $data['id'] );
    10631125        $this->assertEquals( $params['content']['raw'], $new_comment->comment_content );
     
    10731135            'author_email' => 'homer@example.org',
    10741136            'content'      => array(
    1075                 'raw' => 'Aw, he loves beer. Here, little fella.'
     1137                'raw' => 'Aw, he loves beer. Here, little fella.',
    10761138            ),
    10771139        );
     
    12321294
    12331295    public function test_create_item_assign_different_user() {
    1234         $subscriber_id = $this->factory->user->create( array(
    1235             'role' => 'subscriber',
    1236             'user_email' => 'cbg@androidsdungeon.com',
    1237         ));
    1238 
    1239         wp_set_current_user( self::$admin_id );
    1240         $params = array(
    1241             'post'    => self::$post_id,
     1296        $subscriber_id = $this->factory->user->create(
     1297            array(
     1298                'role'       => 'subscriber',
     1299                'user_email' => 'cbg@androidsdungeon.com',
     1300            )
     1301        );
     1302
     1303        wp_set_current_user( self::$admin_id );
     1304        $params  = array(
     1305            'post'         => self::$post_id,
    12421306            'author_name'  => 'Comic Book Guy',
    12431307            'author_email' => 'cbg@androidsdungeon.com',
    12441308            'author_url'   => 'http://androidsdungeon.com',
    1245             'author' => $subscriber_id,
    1246             'content' => 'Worst Comment Ever!',
    1247             'date'    => '2014-11-07T10:14:25',
     1309            'author'       => $subscriber_id,
     1310            'content'      => 'Worst Comment Ever!',
     1311            'date'         => '2014-11-07T10:14:25',
    12481312        );
    12491313        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     
    12631327
    12641328        $params = array(
    1265             'post'    => $post_id,
     1329            'post'         => $post_id,
    12661330            'author'       => self::$admin_id,
    12671331            'author_name'  => 'Comic Book Guy',
    12681332            'author_email' => 'cbg@androidsdungeon.com',
    12691333            'author_url'   => 'http://androidsdungeon.com',
    1270             'content' => 'Worst Comment Ever!',
    1271             'date'    => '2014-11-07T10:14:25',
     1334            'content'      => 'Worst Comment Ever!',
     1335            'date'         => '2014-11-07T10:14:25',
    12721336        );
    12731337
     
    12881352        $collection->set_param( 'post', $post_id );
    12891353        $collection_response = $this->server->dispatch( $collection );
    1290         $collection_data = $collection_response->get_data();
     1354        $collection_data     = $collection_response->get_data();
    12911355        $this->assertEquals( $comment_id, $collection_data[0]['id'] );
    12921356    }
     
    13001364
    13011365        $params = array(
    1302             'post'    => $post_id,
     1366            'post'         => $post_id,
    13031367            'author'       => self::$admin_id,
    13041368            'author_name'  => 'Comic Book Guy',
    13051369            'author_email' => 'cbg@androidsdungeon.com',
    13061370            'author_url'   => 'http://androidsdungeon.com',
    1307             'content' => 'Worst Comment Ever!',
    1308             'date'    => '2014-11-07T10:14:25',
    1309             'type' => 'foo',
     1371            'content'      => 'Worst Comment Ever!',
     1372            'date'         => '2014-11-07T10:14:25',
     1373            'type'         => 'foo',
    13101374        );
    13111375
     
    13231387
    13241388        $params = array(
    1325             'post'  => $post_id,
    1326             'author'       => self::$admin_id,
     1389            'post'         => $post_id,
     1390            'author'       => self::$admin_id,
    13271391            'author_name'  => 'Comic Book Guy',
    13281392            'author_email' => 'hello:)',
    13291393            'author_url'   => 'http://androidsdungeon.com',
    1330             'content' => 'Worst Comment Ever!',
    1331             'date'  => '2014-11-07T10:14:25',
     1394            'content'      => 'Worst Comment Ever!',
     1395            'date'         => '2014-11-07T10:14:25',
    13321396        );
    13331397
     
    13411405
    13421406    public function test_create_item_current_user() {
    1343         $user_id = $this->factory->user->create( array(
    1344             'role' => 'subscriber',
    1345             'user_email' => 'lylelanley@example.com',
    1346             'first_name' => 'Lyle',
    1347             'last_name' => 'Lanley',
    1348             'display_name' => 'Lyle Lanley',
    1349             'user_url' => 'http://simpsons.wikia.com/wiki/Lyle_Lanley',
    1350         ));
     1407        $user_id = $this->factory->user->create(
     1408            array(
     1409                'role'         => 'subscriber',
     1410                'user_email'   => 'lylelanley@example.com',
     1411                'first_name'   => 'Lyle',
     1412                'last_name'    => 'Lanley',
     1413                'display_name' => 'Lyle Lanley',
     1414                'user_url'     => 'http://simpsons.wikia.com/wiki/Lyle_Lanley',
     1415            )
     1416        );
    13511417
    13521418        wp_set_current_user( $user_id );
    13531419
    13541420        $params = array(
    1355             'post' => self::$post_id,
     1421            'post'    => self::$post_id,
    13561422            'content' => "Well sir, there's nothing on earth like a genuine, bona fide, electrified, six-car Monorail!",
    13571423        );
     
    13671433
    13681434        // Check author data matches
    1369         $author = get_user_by( 'id', $user_id );
     1435        $author  = get_user_by( 'id', $user_id );
    13701436        $comment = get_comment( $data['id'] );
    13711437        $this->assertEquals( $author->display_name, $comment->comment_author );
     
    13781444
    13791445        $params = array(
    1380             'post'    => self::$post_id,
     1446            'post'         => self::$post_id,
    13811447            'author_name'  => 'Homer Jay Simpson',
    13821448            'author_email' => 'chunkylover53@aol.com',
    13831449            'author_url'   => 'http://compuglobalhypermeganet.com',
    1384             'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
    1385             'author'    => self::$subscriber_id,
     1450            'content'      => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
     1451            'author'       => self::$subscriber_id,
    13861452        );
    13871453
     
    14231489
    14241490        $params = array(
    1425             'post'         => 'some-slug',
     1491            'post'         => 'some-slug',
    14261492            'author_name'  => 'Homer Jay Simpson',
    14271493            'author_email' => 'chunkylover53@aol.com',
    14281494            'author_url'   => 'http://compuglobalhypermeganet.com',
    1429             'content'      => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
    1430             'author'       => self::$subscriber_id,
     1495            'content'      => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
     1496            'author'       => self::$subscriber_id,
    14311497        );
    14321498
     
    14491515            'content'      => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
    14501516            'author'       => self::$subscriber_id,
    1451             'status'        => 'approved',
     1517            'status'       => 'approved',
    14521518        );
    14531519
     
    14651531
    14661532        $params = array(
    1467             'post'         => $post_id,
    1468             'author_name'  => 'Comic Book Guy',
    1469             'author_email' => 'cbg@androidsdungeon.com',
    1470             'author_ip'    => '139.130.4.5',
    1471             'author_url'   => 'http://androidsdungeon.com',
     1533            'post'              => $post_id,
     1534            'author_name'       => 'Comic Book Guy',
     1535            'author_email'      => 'cbg@androidsdungeon.com',
     1536            'author_ip'         => '139.130.4.5',
     1537            'author_url'        => 'http://androidsdungeon.com',
    14721538            'author_user_agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
    1473             'content'      => 'Worst Comment Ever!',
    1474             'status'       => 'approved',
     1539            'content'           => 'Worst Comment Ever!',
     1540            'status'            => 'approved',
    14751541        );
    14761542
     
    15161582        wp_set_current_user( self::$admin_id );
    15171583
    1518         $params = array(
     1584        $params  = array(
    15191585            'post'         => self::$post_id,
    15201586            'author_name'  => 'Comic Book Guy',
     
    15281594        $request->add_header( 'content-type', 'application/json' );
    15291595        $request->set_body( wp_json_encode( $params ) );
    1530         $response = $this->server->dispatch( $request );
    1531         $data = $response->get_data();
     1596        $response    = $this->server->dispatch( $request );
     1597        $data        = $response->get_data();
    15321598        $new_comment = get_comment( $data['id'] );
    15331599        $this->assertEquals( '127.0.0.3', $new_comment->comment_author_IP );
     
    15371603        wp_set_current_user( self::$admin_id );
    15381604
    1539         $params = array(
     1605        $params  = array(
    15401606            'post'         => self::$post_id,
    15411607            'author_name'  => 'Comic Book Guy',
     
    15561622    public function test_create_comment_author_ip_no_permission() {
    15571623        wp_set_current_user( self::$subscriber_id );
    1558         $params = array(
     1624        $params  = array(
    15591625            'author_name'  => 'Comic Book Guy',
    15601626            'author_email' => 'cbg@androidsdungeon.com',
     
    15741640        wp_set_current_user( self::$admin_id );
    15751641        $_SERVER['REMOTE_ADDR'] = '127.0.0.2';
    1576         $params = array(
     1642        $params                 = array(
    15771643            'post'         => self::$post_id,
    15781644            'author_name'  => 'Comic Book Guy',
     
    15811647            'content'      => 'Worst Comment Ever!',
    15821648        );
    1583         $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1584         $request->add_header( 'content-type', 'application/json' );
    1585         $request->set_body( wp_json_encode( $params ) );
    1586         $response = $this->server->dispatch( $request );
    1587         $data = $response->get_data();
     1649        $request                = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1650        $request->add_header( 'content-type', 'application/json' );
     1651        $request->set_body( wp_json_encode( $params ) );
     1652        $response    = $this->server->dispatch( $request );
     1653        $data        = $response->get_data();
    15881654        $new_comment = get_comment( $data['id'] );
    15891655        $this->assertEquals( '127.0.0.2', $new_comment->comment_author_IP );
     
    15931659        wp_set_current_user( self::$admin_id );
    15941660
    1595         $params = array(
     1661        $params  = array(
    15961662            'author_name'  => 'Comic Book Guy',
    15971663            'author_email' => 'cbg@androidsdungeon.com',
     
    16121678        wp_set_current_user( self::$subscriber_id );
    16131679
    1614         $params = array(
     1680        $params  = array(
    16151681            'author_name'  => 'Homer Jay Simpson',
    16161682            'author_email' => 'chunkylover53@aol.com',
     
    16501716        wp_set_current_user( self::$subscriber_id );
    16511717
    1652         $params = array(
     1718        $params  = array(
    16531719            'post'         => self::$draft_id,
    16541720            'author_name'  => 'Ishmael',
     
    16701736        wp_set_current_user( self::$subscriber_id );
    16711737
    1672         $params = array(
     1738        $params  = array(
    16731739            'post'         => self::$trash_id,
    16741740            'author_name'  => 'Ishmael',
     
    16901756        wp_set_current_user( self::$subscriber_id );
    16911757
    1692         $params = array(
     1758        $params  = array(
    16931759            'post'         => self::$private_id,
    16941760            'author_name'  => 'Homer Jay Simpson',
     
    17101776        wp_set_current_user( self::$subscriber_id );
    17111777
    1712         $params = array(
     1778        $params  = array(
    17131779            'post'         => self::$password_id,
    17141780            'author_name'  => 'Homer Jay Simpson',
     
    17381804
    17391805        $params = array(
    1740             'post'    => self::$post_id,
     1806            'post'         => self::$post_id,
    17411807            'author_name'  => 'Guy N. Cognito',
    17421808            'author_email' => 'chunkylover53@aol.co.uk',
    1743             'content' => 'Homer? Who is Homer? My name is Guy N. Cognito.',
     1809            'content'      => 'Homer? Who is Homer? My name is Guy N. Cognito.',
    17441810        );
    17451811
     
    17531819
    17541820    public function test_create_comment_closed() {
    1755         $post_id = $this->factory->post->create( array(
    1756             'comment_status' => 'closed',
    1757         ));
     1821        $post_id = $this->factory->post->create(
     1822            array(
     1823                'comment_status' => 'closed',
     1824            )
     1825        );
    17581826        wp_set_current_user( self::$subscriber_id );
    17591827
    17601828        $params = array(
    1761             'post'      => $post_id,
     1829            'post' => $post_id,
    17621830        );
    17631831
     
    17861854
    17871855        $params = array(
    1788             'post'         => self::$post_id,
    1789             'author'       => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
    1790             'content'      => 'It\'s all over\, people! We don\'t have a prayer!',
     1856            'post'    => self::$post_id,
     1857            'author'  => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
     1858            'content' => 'It\'s all over\, people! We don\'t have a prayer!',
    17911859        );
    17921860
     
    18041872        $author = new WP_User( self::$author_id );
    18051873        $params = array(
    1806             'post'         => self::$post_id,
    1807             'author'       => self::$author_id,
    1808             'content'      => 'It\'s all over\, people! We don\'t have a prayer!',
     1874            'post'    => self::$post_id,
     1875            'author'  => self::$author_id,
     1876            'content' => 'It\'s all over\, people! We don\'t have a prayer!',
    18091877        );
    18101878
     
    18261894
    18271895        $params = array(
    1828             'post'    => self::$post_id,
    1829             'author_name'  => 'Comic Book Guy',
    1830             'author_email' => 'cbg@androidsdungeon.com',
    1831             'author_url'   => 'http://androidsdungeon.com',
    1832             'content' => 'Worst Comment Ever!',
    1833         );
    1834 
    1835         $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1836         $request->add_header( 'content-type', 'application/json' );
    1837         $request->set_body( wp_json_encode( $params ) );
    1838 
    1839         $response = $this->server->dispatch( $request );
    1840         $this->assertEquals( 201, $response->get_status() );
    1841 
    1842         $params = array(
    1843             'post'    => self::$post_id,
    1844             'author_name'  => 'Comic Book Guy',
    1845             'author_email' => 'cbg@androidsdungeon.com',
    1846             'author_url'   => 'http://androidsdungeon.com',
    1847             'content'      => 'Shakes fist at sky',
    1848         );
    1849 
    1850         $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    1851         $request->add_header( 'content-type', 'application/json' );
    1852         $request->set_body( wp_json_encode( $params ) );
    1853 
    1854         $response = $this->server->dispatch( $request );
    1855         $this->assertEquals( 400, $response->get_status() );
    1856     }
    1857 
    1858     public function anonymous_comments_callback_null() {
    1859         // I'm a plugin developer who forgot to include a return value for some
    1860         // code path in my 'rest_allow_anonymous_comments' filter.
    1861     }
    1862 
    1863     public function test_allow_anonymous_comments_null() {
    1864         add_filter( 'rest_allow_anonymous_comments', array( $this, 'anonymous_comments_callback_null' ), 10, 2 );
    1865 
    1866         $params = array(
    18671896            'post'         => self::$post_id,
    18681897            'author_name'  => 'Comic Book Guy',
     
    18771906
    18781907        $response = $this->server->dispatch( $request );
     1908        $this->assertEquals( 201, $response->get_status() );
     1909
     1910        $params = array(
     1911            'post'         => self::$post_id,
     1912            'author_name'  => 'Comic Book Guy',
     1913            'author_email' => 'cbg@androidsdungeon.com',
     1914            'author_url'   => 'http://androidsdungeon.com',
     1915            'content'      => 'Shakes fist at sky',
     1916        );
     1917
     1918        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1919        $request->add_header( 'content-type', 'application/json' );
     1920        $request->set_body( wp_json_encode( $params ) );
     1921
     1922        $response = $this->server->dispatch( $request );
     1923        $this->assertEquals( 400, $response->get_status() );
     1924    }
     1925
     1926    public function anonymous_comments_callback_null() {
     1927        // I'm a plugin developer who forgot to include a return value for some
     1928        // code path in my 'rest_allow_anonymous_comments' filter.
     1929    }
     1930
     1931    public function test_allow_anonymous_comments_null() {
     1932        add_filter( 'rest_allow_anonymous_comments', array( $this, 'anonymous_comments_callback_null' ), 10, 2 );
     1933
     1934        $params = array(
     1935            'post'         => self::$post_id,
     1936            'author_name'  => 'Comic Book Guy',
     1937            'author_email' => 'cbg@androidsdungeon.com',
     1938            'author_url'   => 'http://androidsdungeon.com',
     1939            'content'      => 'Worst Comment Ever!',
     1940        );
     1941
     1942        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1943        $request->add_header( 'content-type', 'application/json' );
     1944        $request->set_body( wp_json_encode( $params ) );
     1945
     1946        $response = $this->server->dispatch( $request );
    18791947
    18801948        remove_filter( 'rest_allow_anonymous_comments', array( $this, 'anonymous_comments_callback_null' ), 10, 2 );
     
    18891957        wp_set_current_user( self::$subscriber_id );
    18901958
    1891         $params = array(
     1959        $params  = array(
    18921960            'post'         => self::$post_id,
    18931961            'author_name'  => rand_long_str( 246 ),
     
    19121980        wp_set_current_user( self::$subscriber_id );
    19131981
    1914         $params = array(
     1982        $params  = array(
    19151983            'post'         => self::$post_id,
    19161984            'author_name'  => 'Bleeding Gums Murphy',
     
    19352003        wp_set_current_user( self::$subscriber_id );
    19362004
    1937         $params = array(
     2005        $params  = array(
    19382006            'post'         => self::$post_id,
    19392007            'author_name'  => 'Bleeding Gums Murphy',
     
    19582026        wp_set_current_user( self::$subscriber_id );
    19592027
    1960         $params = array(
     2028        $params  = array(
    19612029            'post'         => self::$post_id,
    19622030            'author_name'  => 'Bleeding Gums Murphy',
     
    19782046        wp_set_current_user( self::$subscriber_id );
    19792047
    1980         $params = array(
     2048        $params  = array(
    19812049            'post'         => self::$password_id,
    19822050            'author_name'  => 'Bleeding Gums Murphy',
     
    19972065        add_filter( 'rest_allow_anonymous_comments', '__return_true' );
    19982066
    1999         $params = array(
     2067        $params  = array(
    20002068            'post'         => self::$password_id,
    20012069            'author_name'  => 'Bleeding Gums Murphy',
     
    20182086        wp_set_current_user( self::$admin_id );
    20192087
    2020         $params = array(
     2088        $params  = array(
    20212089            'author'       => self::$subscriber_id,
    20222090            'author_name'  => 'Disco Stu',
     
    20702138
    20712139        $this->assertEquals( 200, $response->get_status() );
    2072         $data = $response->get_data();
     2140        $data    = $response->get_data();
    20732141        $comment = get_comment( $data['id'] );
    20742142
     
    21202188        wp_set_current_user( self::$admin_id );
    21212189
    2122         $comment_id = $this->factory->comment->create( array(
    2123             'comment_approved' => 0,
    2124             'comment_post_ID'  => self::$post_id,
    2125         ));
    2126 
    2127         $params = array(
     2190        $comment_id = $this->factory->comment->create(
     2191            array(
     2192                'comment_approved' => 0,
     2193                'comment_post_ID'  => self::$post_id,
     2194            )
     2195        );
     2196
     2197        $params  = array(
    21282198            'status' => 'approve',
    21292199        );
     
    21442214        wp_set_current_user( self::$admin_id );
    21452215
    2146         $comment_id = $this->factory->comment->create( array(
    2147             'comment_approved' => 0,
    2148             'comment_post_ID'  => self::$post_id,
    2149             'comment_content'  => 'some content',
    2150         ));
    2151 
    2152         $params = array(
     2216        $comment_id = $this->factory->comment->create(
     2217            array(
     2218                'comment_approved' => 0,
     2219                'comment_post_ID'  => self::$post_id,
     2220                'comment_content'  => 'some content',
     2221            )
     2222        );
     2223
     2224        $params  = array(
    21532225            'status' => 'approve',
    21542226        );
     
    21702242        wp_set_current_user( self::$admin_id );
    21712243
    2172         $params = array(
     2244        $params  = array(
    21732245            'date_gmt' => '2015-05-07T10:14:25',
    21742246            'content'  => 'I\'ll be deep in the cold, cold ground before I recognize Missouri.',
     
    22842356        wp_set_current_user( self::$admin_id );
    22852357
    2286         $params = array(
     2358        $params  = array(
    22872359            'type' => 'trackback',
    22882360        );
     
    22982370        wp_set_current_user( self::$admin_id );
    22992371
    2300         $params = array(
     2372        $params  = array(
    23012373            'content' => array(
    23022374                'raw' => 'What the heck kind of name is Persephone?',
     
    23512423        wp_set_current_user( self::$subscriber_id );
    23522424
    2353         $params = array(
     2425        $params  = array(
    23542426            'content' => 'Oh, they have the internet on computers now!',
    23552427        );
     
    23752447        add_filter( 'rest_allow_anonymous_comments', '__return_true' );
    23762448
    2377         $params = array(
     2449        $params  = array(
    23782450            'content' => 'Disco Stu likes disco music.',
    23792451        );
     
    23872459
    23882460    public function test_update_comment_private_post_invalid_permission() {
    2389         $private_comment_id = $this->factory->comment->create( array(
    2390             'comment_approved' => 1,
    2391             'comment_post_ID'  => self::$private_id,
    2392             'user_id'          => 0,
    2393         ));
     2461        $private_comment_id = $this->factory->comment->create(
     2462            array(
     2463                'comment_approved' => 1,
     2464                'comment_post_ID'  => self::$private_id,
     2465                'user_id'          => 0,
     2466            )
     2467        );
    23942468
    23952469        wp_set_current_user( self::$subscriber_id );
    23962470
    2397         $params = array(
     2471        $params  = array(
    23982472            'content' => 'Disco Stu likes disco music.',
    23992473        );
     
    24082482    public function test_update_comment_with_children_link() {
    24092483        wp_set_current_user( self::$admin_id );
    2410         $comment_id_1 = $this->factory->comment->create( array(
    2411             'comment_approved' => 1,
    2412             'comment_post_ID'  => self::$post_id,
    2413             'user_id'          => self::$subscriber_id,
    2414         ) );
    2415 
    2416         $child_comment = $this->factory->comment->create( array(
    2417             'comment_approved' => 1,
    2418             'comment_post_ID'  => self::$post_id,
    2419             'user_id'          => self::$subscriber_id,
    2420         ) );
     2484        $comment_id_1 = $this->factory->comment->create(
     2485            array(
     2486                'comment_approved' => 1,
     2487                'comment_post_ID'  => self::$post_id,
     2488                'user_id'          => self::$subscriber_id,
     2489            )
     2490        );
     2491
     2492        $child_comment = $this->factory->comment->create(
     2493            array(
     2494                'comment_approved' => 1,
     2495                'comment_post_ID'  => self::$post_id,
     2496                'user_id'          => self::$subscriber_id,
     2497            )
     2498        );
    24212499
    24222500        // Check if comment 1 does not have the child link.
    2423         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
     2501        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
    24242502        $response = $this->server->dispatch( $request );
    24252503        $this->assertEquals( 200, $response->get_status() );
     
    24342512
    24352513        // Check if comment 1 now has the child link.
    2436         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
     2514        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
    24372515        $response = $this->server->dispatch( $request );
    24382516        $this->assertEquals( 200, $response->get_status() );
     
    24462524        wp_set_current_user( self::$admin_id );
    24472525
    2448         $params = array(
     2526        $params  = array(
    24492527            'author_name' => rand_long_str( 246 ),
    24502528            'content'     => 'This isn\'t a saxophone. It\'s an umbrella.',
     
    24652543        wp_set_current_user( self::$admin_id );
    24662544
    2467         $params = array(
     2545        $params  = array(
    24682546            'author_email' => 'murphy@' . rand_long_str( 190 ) . '.com',
    24692547            'content'      => 'This isn\'t a saxophone. It\'s an umbrella.',
     
    24842562        wp_set_current_user( self::$admin_id );
    24852563
    2486         $params = array(
     2564        $params  = array(
    24872565            'author_url' => 'http://jazz.' . rand_long_str( 185 ) . '.com',
    24882566            'content'    => 'This isn\'t a saxophone. It\'s an umbrella.',
     
    25032581        wp_set_current_user( self::$admin_id );
    25042582
    2505         $params = array(
     2583        $params  = array(
    25062584            'content' => rand_long_str( 66525 ),
    25072585        );
     
    25302608        $this->assertInternalType( 'array', $actual_output['content'] );
    25312609        $this->assertArrayHasKey( 'raw', $actual_output['content'] );
    2532         $this->assertEquals( $expected_output['content']['raw']     , $actual_output['content']['raw'] );
     2610        $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] );
    25332611        $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );
    2534         $this->assertEquals( $expected_output['author_name']        , $actual_output['author_name'] );
    2535         $this->assertEquals( $expected_output['author_user_agent']  , $actual_output['author_user_agent'] );
     2612        $this->assertEquals( $expected_output['author_name'], $actual_output['author_name'] );
     2613        $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] );
    25362614
    25372615        // Compare expected API output to WP internal values
    25382616        $comment = get_comment( $actual_output['id'] );
    2539         $this->assertEquals( $expected_output['content']['raw']   , $comment->comment_content );
    2540         $this->assertEquals( $expected_output['author_name']      , $comment->comment_author );
     2617        $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content );
     2618        $this->assertEquals( $expected_output['author_name'], $comment->comment_author );
    25412619        $this->assertEquals( $expected_output['author_user_agent'], $comment->comment_agent );
    25422620
     
    25542632
    25552633        // Compare expected API output to actual API output
    2556         $this->assertEquals( $expected_output['content']['raw']     , $actual_output['content']['raw'] );
     2634        $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] );
    25572635        $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );
    2558         $this->assertEquals( $expected_output['author_name']        , $actual_output['author_name'] );
    2559         $this->assertEquals( $expected_output['author_user_agent']  , $actual_output['author_user_agent'] );
     2636        $this->assertEquals( $expected_output['author_name'], $actual_output['author_name'] );
     2637        $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] );
    25602638
    25612639        // Compare expected API output to WP internal values
    25622640        $comment = get_comment( $actual_output['id'] );
    2563         $this->assertEquals( $expected_output['content']['raw']   , $comment->comment_content );
    2564         $this->assertEquals( $expected_output['author_name']      , $comment->comment_author );
     2641        $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content );
     2642        $this->assertEquals( $expected_output['author_name'], $comment->comment_author );
    25652643        $this->assertEquals( $expected_output['author_user_agent'], $comment->comment_agent );
    25662644    }
     
    25692647        wp_set_current_user( self::$editor_id );
    25702648        $this->assertEquals( ! is_multisite(), current_user_can( 'unfiltered_html' ) );
    2571         $this->verify_comment_roundtrip( array(
    2572             'content'           => '\o/ ¯\_(ツ)_/¯',
    2573             'author_name'       => '\o/ ¯\_(ツ)_/¯',
    2574             'author_user_agent' => '\o/ ¯\_(ツ)_/¯',
    2575         ), array(
    2576             'content' => array(
    2577                 'raw'      => '\o/ ¯\_(ツ)_/¯',
    2578                 'rendered' => '<p>\o/ ¯\_(ツ)_/¯</p>',
    2579             ),
    2580             'author_name'       => '\o/ ¯\_(ツ)_/¯',
    2581             'author_user_agent' => '\o/ ¯\_(ツ)_/¯',
    2582         ) );
     2649        $this->verify_comment_roundtrip(
     2650            array(
     2651                'content'           => '\o/ ¯\_(ツ)_/¯',
     2652                'author_name'       => '\o/ ¯\_(ツ)_/¯',
     2653                'author_user_agent' => '\o/ ¯\_(ツ)_/¯',
     2654            ), array(
     2655                'content'           => array(
     2656                    'raw'      => '\o/ ¯\_(ツ)_/¯',
     2657                    'rendered' => '<p>\o/ ¯\_(ツ)_/¯</p>',
     2658                ),
     2659                'author_name'       => '\o/ ¯\_(ツ)_/¯',
     2660                'author_user_agent' => '\o/ ¯\_(ツ)_/¯',
     2661            )
     2662        );
    25832663    }
    25842664
     
    25872667        if ( is_multisite() ) {
    25882668            $this->assertFalse( current_user_can( 'unfiltered_html' ) );
    2589             $this->verify_comment_roundtrip( array(
     2669            $this->verify_comment_roundtrip(
     2670                array(
     2671                    'content'           => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2672                    'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2673                    'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2674                ), array(
     2675                    'content'           => array(
     2676                        'raw'      => 'div <strong>strong</strong> oh noes',
     2677                        'rendered' => '<p>div <strong>strong</strong> oh noes</p>',
     2678                    ),
     2679                    'author_name'       => 'div strong',
     2680                    'author_user_agent' => 'div strong',
     2681                )
     2682            );
     2683        } else {
     2684            $this->assertTrue( current_user_can( 'unfiltered_html' ) );
     2685            $this->verify_comment_roundtrip(
     2686                array(
     2687                    'content'           => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2688                    'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2689                    'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2690                ), array(
     2691                    'content'           => array(
     2692                        'raw'      => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2693                        'rendered' => "<div>div</div>\n<p> <strong>strong</strong> <script>oh noes</script></p>",
     2694                    ),
     2695                    'author_name'       => 'div strong',
     2696                    'author_user_agent' => 'div strong',
     2697                )
     2698            );
     2699        }
     2700    }
     2701
     2702    public function test_comment_roundtrip_as_superadmin() {
     2703        wp_set_current_user( self::$superadmin_id );
     2704        $this->assertTrue( current_user_can( 'unfiltered_html' ) );
     2705        $this->verify_comment_roundtrip(
     2706            array(
     2707                'content'           => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2708                'author_name'       => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2709                'author_user_agent' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2710            ), array(
     2711                'content'           => array(
     2712                    'raw'      => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2713                    'rendered' => '<p>\\\&#038;\\\ &amp; &invalid; < &lt; &amp;lt;' . "\n</p>",
     2714                ),
     2715                'author_name'       => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
     2716                'author_user_agent' => '\\\&\\\ &amp; &invalid; &lt; &lt; &amp;lt;',
     2717            )
     2718        );
     2719    }
     2720
     2721    public function test_comment_roundtrip_as_superadmin_unfiltered_html() {
     2722        wp_set_current_user( self::$superadmin_id );
     2723        $this->assertTrue( current_user_can( 'unfiltered_html' ) );
     2724        $this->verify_comment_roundtrip(
     2725            array(
    25902726                'content'           => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    25912727                'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    25922728                'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    25932729            ), array(
    2594                 'content' => array(
    2595                     'raw'      => 'div <strong>strong</strong> oh noes',
    2596                     'rendered' => '<p>div <strong>strong</strong> oh noes</p>',
    2597                 ),
    2598                 'author_name'       => 'div strong',
    2599                 'author_user_agent' => 'div strong',
    2600             ) );
    2601         } else {
    2602             $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    2603             $this->verify_comment_roundtrip( array(
    2604                 'content'           => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    2605                 'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    2606                 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    2607             ), array(
    2608                 'content' => array(
     2730                'content'           => array(
    26092731                    'raw'      => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    26102732                    'rendered' => "<div>div</div>\n<p> <strong>strong</strong> <script>oh noes</script></p>",
     
    26122734                'author_name'       => 'div strong',
    26132735                'author_user_agent' => 'div strong',
    2614             ) );
    2615         }
    2616     }
    2617 
    2618     public function test_comment_roundtrip_as_superadmin() {
    2619         wp_set_current_user( self::$superadmin_id );
    2620         $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    2621         $this->verify_comment_roundtrip( array(
    2622             'content'           => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    2623             'author_name'       => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    2624             'author_user_agent' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    2625         ), array(
    2626             'content' => array(
    2627                 'raw'      => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    2628                 'rendered' => '<p>\\\&#038;\\\ &amp; &invalid; < &lt; &amp;lt;' . "\n</p>",
    2629             ),
    2630             'author_name'       => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    2631             'author_user_agent' => '\\\&\\\ &amp; &invalid; &lt; &lt; &amp;lt;',
    2632         ) );
    2633     }
    2634 
    2635     public function test_comment_roundtrip_as_superadmin_unfiltered_html() {
    2636         wp_set_current_user( self::$superadmin_id );
    2637         $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    2638         $this->verify_comment_roundtrip( array(
    2639             'content'           => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    2640             'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    2641             'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    2642         ), array(
    2643             'content' => array(
    2644                 'raw'      => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    2645                 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> <script>oh noes</script></p>",
    2646             ),
    2647             'author_name'       => 'div strong',
    2648             'author_user_agent' => 'div strong',
    2649         ) );
     2736            )
     2737        );
    26502738    }
    26512739
     
    26532741        wp_set_current_user( self::$admin_id );
    26542742
    2655         $comment_id = $this->factory->comment->create( array(
    2656             'comment_approved' => 1,
    2657             'comment_post_ID'  => self::$post_id,
    2658             'user_id'          => self::$subscriber_id,
    2659         ));
     2743        $comment_id = $this->factory->comment->create(
     2744            array(
     2745                'comment_approved' => 1,
     2746                'comment_post_ID'  => self::$post_id,
     2747                'user_id'          => self::$subscriber_id,
     2748            )
     2749        );
    26602750
    26612751        $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
     
    26712761        wp_set_current_user( self::$admin_id );
    26722762
    2673         $comment_id = $this->factory->comment->create( array(
    2674             'comment_approved' => 1,
    2675             'comment_post_ID'  => self::$post_id,
    2676             'user_id'          => self::$subscriber_id,
    2677         ));
    2678         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
     2763        $comment_id       = $this->factory->comment->create(
     2764            array(
     2765                'comment_approved' => 1,
     2766                'comment_post_ID'  => self::$post_id,
     2767                'user_id'          => self::$subscriber_id,
     2768            )
     2769        );
     2770        $request          = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
    26792771        $request['force'] = true;
    26802772
     
    26892781        wp_set_current_user( self::$admin_id );
    26902782
    2691         $comment_id = $this->factory->comment->create( array(
    2692             'comment_approved' => 1,
    2693             'comment_post_ID'  => self::$post_id,
    2694             'user_id'          => self::$subscriber_id,
    2695         ));
    2696         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
    2697         $response = $this->server->dispatch( $request );
    2698         $this->assertEquals( 200, $response->get_status() );
    2699         $data = $response->get_data();
     2783        $comment_id = $this->factory->comment->create(
     2784            array(
     2785                'comment_approved' => 1,
     2786                'comment_post_ID'  => self::$post_id,
     2787                'user_id'          => self::$subscriber_id,
     2788            )
     2789        );
     2790        $request    = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
     2791        $response   = $this->server->dispatch( $request );
     2792        $this->assertEquals( 200, $response->get_status() );
     2793        $data     = $response->get_data();
    27002794        $response = $this->server->dispatch( $request );
    27012795        $this->assertErrorResponse( 'rest_already_trashed', $response, 410 );
     
    27222816    public function test_delete_child_comment_link() {
    27232817        wp_set_current_user( self::$admin_id );
    2724         $comment_id_1 = $this->factory->comment->create( array(
    2725             'comment_approved' => 1,
    2726             'comment_post_ID'  => self::$post_id,
    2727             'user_id'          => self::$subscriber_id,
    2728         ) );
    2729 
    2730         $child_comment = $this->factory->comment->create( array(
    2731             'comment_approved' => 1,
    2732             'comment_parent'   => $comment_id_1,
    2733             'comment_post_ID'  => self::$post_id,
    2734             'user_id'          => self::$subscriber_id,
    2735         ) );
    2736 
    2737         $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) );
     2818        $comment_id_1 = $this->factory->comment->create(
     2819            array(
     2820                'comment_approved' => 1,
     2821                'comment_post_ID'  => self::$post_id,
     2822                'user_id'          => self::$subscriber_id,
     2823            )
     2824        );
     2825
     2826        $child_comment = $this->factory->comment->create(
     2827            array(
     2828                'comment_approved' => 1,
     2829                'comment_parent'   => $comment_id_1,
     2830                'comment_post_ID'  => self::$post_id,
     2831                'user_id'          => self::$subscriber_id,
     2832            )
     2833        );
     2834
     2835        $request  = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) );
    27382836        $response = $this->server->dispatch( $request );
    27392837        $this->assertEquals( 200, $response->get_status() );
    27402838
    27412839        // Verify children link is gone.
    2742         $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
     2840        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
    27432841        $response = $this->server->dispatch( $request );
    27442842        $this->assertEquals( 200, $response->get_status() );
     
    27472845
    27482846    public function test_get_item_schema() {
    2749         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
    2750         $response = $this->server->dispatch( $request );
    2751         $data = $response->get_data();
     2847        $request    = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
     2848        $response   = $this->server->dispatch( $request );
     2849        $data       = $response->get_data();
    27522850        $properties = $data['schema']['properties'];
    27532851        $this->assertEquals( 17, count( $properties ) );
     
    27792877    public function test_get_item_schema_show_avatar() {
    27802878        update_option( 'show_avatars', false );
    2781         $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
    2782         $response = $this->server->dispatch( $request );
    2783         $data = $response->get_data();
     2879        $request    = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
     2880        $response   = $this->server->dispatch( $request );
     2881        $data       = $response->get_data();
    27842882        $properties = $data['schema']['properties'];
    27852883
     
    27962894        );
    27972895
    2798         register_rest_field( 'comment', 'my_custom_int', array(
    2799             'schema'          => $schema,
    2800             'get_callback'    => array( $this, 'additional_field_get_callback' ),
    2801             'update_callback' => array( $this, 'additional_field_update_callback' ),
    2802         ) );
     2896        register_rest_field(
     2897            'comment', 'my_custom_int', array(
     2898                'schema'          => $schema,
     2899                'get_callback'    => array( $this, 'additional_field_get_callback' ),
     2900                'update_callback' => array( $this, 'additional_field_update_callback' ),
     2901            )
     2902        );
    28032903
    28042904        $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
    28052905
    28062906        $response = $this->server->dispatch( $request );
    2807         $data = $response->get_data();
     2907        $data     = $response->get_data();
    28082908
    28092909        $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] );
     
    28162916
    28172917        $request = new WP_REST_Request( 'POST', '/wp/v2/comments/' . self::$approved_id );
    2818         $request->set_body_params(array(
    2819             'my_custom_int' => 123,
    2820             'content'       => 'abc',
    2821         ));
     2918        $request->set_body_params(
     2919            array(
     2920                'my_custom_int' => 123,
     2921                'content'       => 'abc',
     2922            )
     2923        );
    28222924
    28232925        wp_set_current_user( 1 );
     
    28262928
    28272929        $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    2828         $request->set_body_params(array(
    2829             'my_custom_int' => 123,
    2830             'title'         => 'hello',
    2831             'content'       => 'goodbye',
    2832             'post'          => self::$post_id,
    2833         ));
     2930        $request->set_body_params(
     2931            array(
     2932                'my_custom_int' => 123,
     2933                'title'         => 'hello',
     2934                'content'       => 'goodbye',
     2935                'post'          => self::$post_id,
     2936            )
     2937        );
    28342938
    28352939        $response = $this->server->dispatch( $request );
     
    28492953        );
    28502954
    2851         register_rest_field( 'comment', 'my_custom_int', array(
    2852             'schema'          => $schema,
    2853             'get_callback'    => array( $this, 'additional_field_get_callback' ),
    2854             'update_callback' => array( $this, 'additional_field_update_callback' ),
    2855         ) );
     2955        register_rest_field(
     2956            'comment', 'my_custom_int', array(
     2957                'schema'          => $schema,
     2958                'get_callback'    => array( $this, 'additional_field_get_callback' ),
     2959                'update_callback' => array( $this, 'additional_field_update_callback' ),
     2960            )
     2961        );
    28562962
    28572963        wp_set_current_user( self::$admin_id );
     
    28592965        // Check for error on update.
    28602966        $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
    2861         $request->set_body_params(array(
    2862             'my_custom_int' => 'returnError',
    2863             'content' => 'abc',
    2864         ));
     2967        $request->set_body_params(
     2968            array(
     2969                'my_custom_int' => 'returnError',
     2970                'content'       => 'abc',
     2971            )
     2972        );
    28652973
    28662974        $response = $this->server->dispatch( $request );
     
    28973005        $this->assertEquals( get_comment_link( $comment ), $data['link'] );
    28983006        $this->assertContains( 'author_avatar_urls', $data );
    2899         $this->assertEqualSets( array(
    2900             'self',
    2901             'collection',
    2902             'up',
    2903         ), array_keys( $links ) );
     3007        $this->assertEqualSets(
     3008            array(
     3009                'self',
     3010                'collection',
     3011                'up',
     3012            ), array_keys( $links )
     3013        );
    29043014
    29053015        if ( 'edit' === $context ) {
Note: See TracChangeset for help on using the changeset viewer.