@@ -4140,6 +4140,7 @@ public function test_get_note_with_children_link() {
41404140 */
41414141 public function data_comment_type_provider () {
41424142 return array (
4143+ 'comment type ' => array ( 'comment ' , 5 ),
41434144 'annotation type ' => array ( 'annotation ' , 5 ),
41444145 'discussion type ' => array ( 'discussion ' , 9 ),
41454146 'note type ' => array ( 'note ' , 3 ),
@@ -4172,12 +4173,13 @@ public function test_get_items_type_arg_authenticated( $comment_type, $count ) {
41724173
41734174 $ request = new WP_REST_Request ( 'GET ' , '/wp/v2/comments ' );
41744175 $ request ->set_param ( 'type ' , $ comment_type );
4176+ $ request ->set_param ( 'per_page ' , self ::$ per_page );
41754177
41764178 $ response = rest_get_server ()->dispatch ( $ request );
41774179 $ this ->assertEquals ( 200 , $ response ->get_status () );
41784180
41794181 $ comments = $ response ->get_data ();
4180- $ this ->assertCount ( $ count , $ comments );
4182+ $ this ->assertCount ( ' comment ' === $ comment_type ? $ count + self :: $ total_comments : $ count , $ comments );
41814183 }
41824184
41834185 /**
@@ -4212,8 +4214,10 @@ public function test_get_items_type_arg_unauthenticated( $comment_type, $count )
42124214 $ request ->set_param ( 'per_page ' , self ::$ per_page );
42134215
42144216 $ response = rest_get_server ()->dispatch ( $ request );
4215- $ this ->assertEquals ( 401 , $ response ->get_status () );
4216- $ this ->assertErrorResponse ( 'rest_forbidden_param ' , $ response , 401 );
4217+ $ this ->assertEquals ( 'comment ' === $ comment_type ? 200 : 401 , $ response ->get_status () );
4218+ if ( 'comment ' !== $ comment_type ) {
4219+ $ this ->assertErrorResponse ( 'rest_forbidden_param ' , $ response , 401 );
4220+ }
42174221 }
42184222
42194223 /**
@@ -4244,6 +4248,9 @@ public function test_get_individual_comment_type_unauthenticated( $comment_type,
42444248 $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/comments/%d ' , $ comment_id ) );
42454249 $ response = rest_get_server ()->dispatch ( $ request );
42464250
4247- $ this ->assertEquals ( 401 , $ response ->get_status () );
4251+ $ this ->assertEquals ( 'comment ' === $ comment_type ? 200 : 401 , $ response ->get_status () );
4252+ if ( 'comment ' !== $ comment_type ) {
4253+ $ this ->assertErrorResponse ( 'rest_cannot_read ' , $ response , 401 );
4254+ }
42484255 }
42494256}
0 commit comments