Make WordPress Core

Ticket #38617: 38617.3.diff

File 38617.3.diff, 43.4 KB (added by jnylen0, 8 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
    index 2749b12..405fc91 100644
    a b class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    594594                        'description'       => __( 'Limit result set to attachments of a particular media type.' ),
    595595                        'type'              => 'string',
    596596                        'enum'              => array_keys( $media_types ),
    597                         'validate_callback' => 'rest_validate_request_arg',
    598597                );
    599598
    600599                $params['mime_type'] = array(
  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
    index 3454dc1..fc081f9 100644
    a b class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11021102                                        'type'         => 'string',
    11031103                                        'format'       => 'ipv4',
    11041104                                        'context'      => array( 'edit' ),
    1105                                         'arg_options'  => array(
    1106                                                 'default'           => '127.0.0.1',
    1107                                         ),
     1105                                        'default'      => '127.0.0.1',
    11081106                                ),
    11091107                                'author_name'     => array(
    11101108                                        'description'  => __( 'Display name for the object author.' ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11761174                                        'description'  => __( 'The id for the parent of the object.' ),
    11771175                                        'type'         => 'integer',
    11781176                                        'context'      => array( 'view', 'edit', 'embed' ),
    1179                                         'arg_options'  => array(
    1180                                                 'default'           => 0,
    1181                                         ),
     1177                                        'default'      => 0,
    11821178                                ),
    11831179                                'post'             => array(
    11841180                                        'description'  => __( 'The id of the associated post object.' ),
    11851181                                        'type'         => 'integer',
    11861182                                        'context'      => array( 'view', 'edit' ),
    1187                                         'arg_options'  => array(
    1188                                                 'default'           => 0,
    1189                                         ),
     1183                                        'default'      => 0,
    11901184                                ),
    11911185                                'status'           => array(
    11921186                                        'description'  => __( 'State of the object.' ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12521246                        'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.' ),
    12531247                        'type'              => 'string',
    12541248                        'format'            => 'date-time',
    1255                         'validate_callback' => 'rest_validate_request_arg',
    12561249                );
    12571250
    12581251                $query_params['author'] = array(
    12591252                        'description'       => __( 'Limit result set to comments assigned to specific user ids. Requires authorization.' ),
    1260                         'sanitize_callback' => 'wp_parse_id_list',
    12611253                        'type'              => 'array',
     1254                        'items'             => array(
     1255                                'type'          => 'integer',
     1256                        ),
    12621257                );
    12631258
    12641259                $query_params['author_exclude'] = array(
    12651260                        'description'       => __( 'Ensure result set excludes comments assigned to specific user ids. Requires authorization.' ),
    1266                         'sanitize_callback' => 'wp_parse_id_list',
    12671261                        'type'              => 'array',
     1262                        'items'             => array(
     1263                                'type'          => 'integer',
     1264                        ),
    12681265                );
    12691266
    12701267                $query_params['author_email'] = array(
    12711268                        'default'           => null,
    12721269                        'description'       => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
    12731270                        'format'            => 'email',
    1274                         'sanitize_callback' => 'sanitize_email',
    12751271                        'type'              => 'string',
    12761272                );
    12771273
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12791275                        'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.' ),
    12801276                        'type'              => 'string',
    12811277                        'format'            => 'date-time',
    1282                         'validate_callback' => 'rest_validate_request_arg',
    12831278                );
    12841279
    12851280                $query_params['exclude'] = array(
    12861281                        'description'        => __( 'Ensure result set excludes specific ids.' ),
    12871282                        'type'               => 'array',
     1283                        'items'              => array(
     1284                                'type'           => 'integer',
     1285                        ),
    12881286                        'default'            => array(),
    1289                         'sanitize_callback'  => 'wp_parse_id_list',
    12901287                );
    12911288
    12921289                $query_params['include'] = array(
    12931290                        'description'        => __( 'Limit result set to specific ids.' ),
    12941291                        'type'               => 'array',
     1292                        'items'              => array(
     1293                                'type'           => 'integer',
     1294                        ),
    12951295                        'default'            => array(),
    1296                         'sanitize_callback'  => 'wp_parse_id_list',
    12971296                );
    12981297
    12991298                $query_params['karma'] = array(
    13001299                        'default'           => null,
    13011300                        'description'       => __( 'Limit result set to that of a particular comment karma. Requires authorization.' ),
    1302                         'sanitize_callback' => 'absint',
    13031301                        'type'              => 'integer',
    1304                         'validate_callback'  => 'rest_validate_request_arg',
    13051302                );
    13061303
    13071304                $query_params['offset'] = array(
    13081305                        'description'        => __( 'Offset the result set by a specific number of comments.' ),
    13091306                        'type'               => 'integer',
    1310                         'sanitize_callback'  => 'absint',
    1311                         'validate_callback'  => 'rest_validate_request_arg',
    13121307                );
    13131308
    13141309                $query_params['order']      = array(
    13151310                        'description'           => __( 'Order sort attribute ascending or descending.' ),
    13161311                        'type'                  => 'string',
    1317                         'sanitize_callback'     => 'sanitize_key',
    1318                         'validate_callback'     => 'rest_validate_request_arg',
    13191312                        'default'               => 'desc',
    13201313                        'enum'                  => array(
    13211314                                'asc',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13261319                $query_params['orderby']    = array(
    13271320                        'description'           => __( 'Sort collection by object attribute.' ),
    13281321                        'type'                  => 'string',
    1329                         'sanitize_callback'     => 'sanitize_key',
    1330                         'validate_callback'     => 'rest_validate_request_arg',
    13311322                        'default'               => 'date_gmt',
    13321323                        'enum'                  => array(
    13331324                                'date',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13431334                $query_params['parent'] = array(
    13441335                        'default'           => array(),
    13451336                        'description'       => __( 'Limit result set to resources of specific parent ids.' ),
    1346                         'sanitize_callback' => 'wp_parse_id_list',
    13471337                        'type'              => 'array',
     1338                        'items'             => array(
     1339                                'type'          => 'integer',
     1340                        ),
    13481341                );
    13491342
    13501343                $query_params['parent_exclude'] = array(
    13511344                        'default'           => array(),
    13521345                        'description'       => __( 'Ensure result set excludes specific parent ids.' ),
    1353                         'sanitize_callback' => 'wp_parse_id_list',
    13541346                        'type'              => 'array',
     1347                        'items'             => array(
     1348                                'type'          => 'integer',
     1349                        ),
    13551350                );
    13561351
    13571352                $query_params['post']   = array(
    13581353                        'default'           => array(),
    13591354                        'description'       => __( 'Limit result set to resources assigned to specific post ids.' ),
    13601355                        'type'              => 'array',
    1361                         'sanitize_callback' => 'wp_parse_id_list',
     1356                        'items'             => array(
     1357                                'type'          => 'integer',
     1358                        ),
    13621359                );
    13631360
    13641361                $query_params['status'] = array(
  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index 0122f9a..723fc95 100644
    a b class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19751975                                'items'       => array(
    19761976                                        'type'    => 'integer',
    19771977                                ),
    1978                                 'arg_options' => array(
    1979                                         'sanitize_callback' => 'wp_parse_id_list',
    1980                                 ),
    1981                                 'context'     => array( 'view', 'edit' ),
    1982                         );
    1983                         $schema['properties'][ $base . '_exclude' ] = array(
    1984                                 'description' => sprintf( __( 'The terms in the %s taxonomy that should not be assigned to the object.' ), $taxonomy->name ),
    1985                                 'type'        => 'array',
    1986                                 'items'       => array(
    1987                                         'type'    => 'integer',
    1988                                 ),
    1989                                 'arg_options' => array(
    1990                                         'sanitize_callback' => 'wp_parse_id_list',
    1991                                 ),
    19921978                                'context'     => array( 'view', 'edit' ),
    19931979                        );
    19941980                }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20131999                        'description'        => __( 'Limit response to resources published after a given ISO8601 compliant date.' ),
    20142000                        'type'               => 'string',
    20152001                        'format'             => 'date-time',
    2016                         'validate_callback'  => 'rest_validate_request_arg',
    20172002                );
    20182003
    20192004                if ( post_type_supports( $this->post_type, 'author' ) ) {
    20202005                        $params['author'] = array(
    20212006                                'description'         => __( 'Limit result set to posts assigned to specific authors.' ),
    20222007                                'type'                => 'array',
     2008                                'items'               => array(
     2009                                        'type'            => 'integer',
     2010                                ),
    20232011                                'default'             => array(),
    2024                                 'sanitize_callback'   => 'wp_parse_id_list',
    20252012                        );
    20262013                        $params['author_exclude'] = array(
    20272014                                'description'         => __( 'Ensure result set excludes posts assigned to specific authors.' ),
    20282015                                'type'                => 'array',
     2016                                'items'               => array(
     2017                                        'type'            => 'integer',
     2018                                ),
    20292019                                'default'             => array(),
    2030                                 'sanitize_callback'   => 'wp_parse_id_list',
    20312020                        );
    20322021                }
    20332022
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20352024                        'description'        => __( 'Limit response to resources published before a given ISO8601 compliant date.' ),
    20362025                        'type'               => 'string',
    20372026                        'format'             => 'date-time',
    2038                         'validate_callback'  => 'rest_validate_request_arg',
    20392027                );
    20402028
    20412029                $params['exclude'] = array(
    20422030                        'description'        => __( 'Ensure result set excludes specific ids.' ),
    20432031                        'type'               => 'array',
     2032                        'items'              => array(
     2033                                'type'           => 'integer',
     2034                        ),
    20442035                        'default'            => array(),
    2045                         'sanitize_callback'  => 'wp_parse_id_list',
    20462036                );
    20472037
    20482038                $params['include'] = array(
    20492039                        'description'        => __( 'Limit result set to specific ids.' ),
    20502040                        'type'               => 'array',
     2041                        'items'              => array(
     2042                                'type'           => 'integer',
     2043                        ),
    20512044                        'default'            => array(),
    2052                         'sanitize_callback'  => 'wp_parse_id_list',
    20532045                );
    20542046
    20552047                if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
    20562048                        $params['menu_order'] = array(
    20572049                                'description'        => __( 'Limit result set to resources with a specific menu_order value.' ),
    20582050                                'type'               => 'integer',
    2059                                 'sanitize_callback'  => 'absint',
    2060                                 'validate_callback'  => 'rest_validate_request_arg',
    20612051                        );
    20622052                }
    20632053
    20642054                $params['offset'] = array(
    20652055                        'description'        => __( 'Offset the result set by a specific number of items.' ),
    20662056                        'type'               => 'integer',
    2067                         'sanitize_callback'  => 'absint',
    2068                         'validate_callback'  => 'rest_validate_request_arg',
    20692057                );
    20702058
    20712059                $params['order'] = array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20732061                        'type'               => 'string',
    20742062                        'default'            => 'desc',
    20752063                        'enum'               => array( 'asc', 'desc' ),
    2076                         'validate_callback'  => 'rest_validate_request_arg',
    20772064                );
    20782065
    20792066                $params['orderby'] = array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20882075                                'title',
    20892076                                'slug',
    20902077                        ),
    2091                         'validate_callback'  => 'rest_validate_request_arg',
    20922078                );
    20932079
    20942080                if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21012087                        $params['parent'] = array(
    21022088                                'description'       => __( 'Limit result set to those of particular parent ids.' ),
    21032089                                'type'              => 'array',
    2104                                 'sanitize_callback' => 'wp_parse_id_list',
     2090                                'items'             => array(
     2091                                        'type'          => 'integer',
     2092                                ),
    21052093                                'default'           => array(),
    21062094                        );
    21072095                        $params['parent_exclude'] = array(
    21082096                                'description'       => __( 'Limit result set to all items except those of a particular parent id.' ),
    21092097                                'type'              => 'array',
    2110                                 'sanitize_callback' => 'wp_parse_id_list',
     2098                                'items'             => array(
     2099                                        'type'          => 'integer',
     2100                                ),
    21112101                                'default'           => array(),
    21122102                        );
    21132103                }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21352125                        $params[ $base ] = array(
    21362126                                'description'       => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
    21372127                                'type'              => 'array',
    2138                                 'sanitize_callback' => 'wp_parse_id_list',
     2128                                'items'             => array(
     2129                                        'type'          => 'integer',
     2130                                ),
     2131                                'default'           => array(),
     2132                        );
     2133
     2134                        $params[ $base . '_exclude' ] = array(
     2135                                'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
     2136                                'type'        => 'array',
     2137                                'items'       => array(
     2138                                        'type'    => 'integer',
     2139                                ),
    21392140                                'default'           => array(),
    21402141                        );
    21412142                }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21442145                        $params['sticky'] = array(
    21452146                                'description'       => __( 'Limit result set to items that are sticky.' ),
    21462147                                'type'              => 'boolean',
    2147                                 'sanitize_callback' => 'rest_parse_request_arg',
    21482148                        );
    21492149                }
    21502150
  • src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
    index 98a5e21..0f253a4 100644
    a b class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    301301                $new_params['type'] = array(
    302302                        'description'  => __( 'Limit results to resources associated with a specific post type.' ),
    303303                        'type'         => 'string',
    304                         'validate_callback' => 'rest_validate_request_arg',
    305304                );
    306305                return $new_params;
    307306        }
  • src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
    index ceaa26b..c9f9f91 100644
    a b class WP_REST_Terms_Controller extends WP_REST_Controller { 
    887887                $query_params['exclude'] = array(
    888888                        'description'       => __( 'Ensure result set excludes specific ids.' ),
    889889                        'type'              => 'array',
     890                        'items'             => array(
     891                                'type'          => 'integer',
     892                        ),
    890893                        'default'           => array(),
    891                         'sanitize_callback' => 'wp_parse_id_list',
    892894                );
    893895
    894896                $query_params['include'] = array(
    895897                        'description'       => __( 'Limit result set to specific ids.' ),
    896898                        'type'              => 'array',
     899                        'items'             => array(
     900                                'type'          => 'integer',
     901                        ),
    897902                        'default'           => array(),
    898                         'sanitize_callback' => 'wp_parse_id_list',
    899903                );
    900904
    901905                if ( ! $taxonomy->hierarchical ) {
    902906                        $query_params['offset'] = array(
    903907                                'description'       => __( 'Offset the result set by a specific number of items.' ),
    904908                                'type'              => 'integer',
    905                                 'sanitize_callback' => 'absint',
    906                                 'validate_callback' => 'rest_validate_request_arg',
    907909                        );
    908910                }
    909911
    910912                $query_params['order'] = array(
    911913                        'description'       => __( 'Order sort attribute ascending or descending.' ),
    912914                        'type'              => 'string',
    913                         'sanitize_callback' => 'sanitize_key',
    914915                        'default'           => 'asc',
    915916                        'enum'              => array(
    916917                                'asc',
    917918                                'desc',
    918919                        ),
    919                         'validate_callback' => 'rest_validate_request_arg',
    920920                );
    921921
    922922                $query_params['orderby'] = array(
    923923                        'description'       => __( 'Sort collection by resource attribute.' ),
    924924                        'type'              => 'string',
    925                         'sanitize_callback' => 'sanitize_key',
    926925                        'default'           => 'name',
    927926                        'enum'              => array(
    928927                                'id',
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    933932                                'description',
    934933                                'count',
    935934                        ),
    936                         'validate_callback' => 'rest_validate_request_arg',
    937935                );
    938936
    939937                $query_params['hide_empty'] = array(
    940938                        'description'       => __( 'Whether to hide resources not assigned to any posts.' ),
    941939                        'type'              => 'boolean',
    942940                        'default'           => false,
    943                         'sanitize_callback' => 'rest_sanitize_request_arg',
    944                         'validate_callback' => 'rest_validate_request_arg',
    945941                );
    946942
    947943                if ( $taxonomy->hierarchical ) {
    948944                        $query_params['parent'] = array(
    949945                                'description'       => __( 'Limit result set to resources assigned to a specific parent.' ),
    950946                                'type'              => 'integer',
    951                                 'sanitize_callback' => 'absint',
    952                                 'validate_callback' => 'rest_validate_request_arg',
    953947                        );
    954948                }
    955949
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    957951                        'description'       => __( 'Limit result set to resources assigned to a specific post.' ),
    958952                        'type'              => 'integer',
    959953                        'default'           => null,
    960                         'validate_callback' => 'rest_validate_request_arg',
    961954                );
    962955
    963956                $query_params['slug'] = array(
    964957                        'description'       => __( 'Limit result set to resources with a specific slug.' ),
    965958                        'type'              => 'string',
    966                         'validate_callback' => 'rest_validate_request_arg',
    967959                );
    968960
    969961                return $query_params;
  • src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
    index bb3737d..1256c68 100644
    a b class WP_REST_Users_Controller extends WP_REST_Controller { 
    11021102                                                'type'    => 'string',
    11031103                                        ),
    11041104                                        'context'     => array( 'edit' ),
    1105                                         'arg_options' => array(
    1106                                                 'sanitize_callback' => 'wp_parse_slug_list',
    1107                                         ),
    11081105                                ),
    11091106                                'password'        => array(
    11101107                                        'description' => __( 'Password for the resource (never included).' ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11711168                $query_params['exclude'] = array(
    11721169                        'description'        => __( 'Ensure result set excludes specific ids.' ),
    11731170                        'type'               => 'array',
     1171                        'items'              => array(
     1172                                'type'           => 'integer',
     1173                        ),
    11741174                        'default'            => array(),
    1175                         'sanitize_callback'  => 'wp_parse_id_list',
    11761175                );
    11771176
    11781177                $query_params['include'] = array(
    11791178                        'description'        => __( 'Limit result set to specific ids.' ),
    11801179                        'type'               => 'array',
     1180                        'items'              => array(
     1181                                'type'           => 'integer',
     1182                        ),
    11811183                        'default'            => array(),
    1182                         'sanitize_callback'  => 'wp_parse_id_list',
    11831184                );
    11841185
    11851186                $query_params['offset'] = array(
    11861187                        'description'        => __( 'Offset the result set by a specific number of items.' ),
    11871188                        'type'               => 'integer',
    1188                         'sanitize_callback'  => 'absint',
    1189                         'validate_callback'  => 'rest_validate_request_arg',
    11901189                );
    11911190
    11921191                $query_params['order'] = array(
    11931192                        'default'            => 'asc',
    11941193                        'description'        => __( 'Order sort attribute ascending or descending.' ),
    11951194                        'enum'               => array( 'asc', 'desc' ),
    1196                         'sanitize_callback'  => 'sanitize_key',
    11971195                        'type'               => 'string',
    1198                         'validate_callback'  => 'rest_validate_request_arg',
    11991196                );
    12001197
    12011198                $query_params['orderby'] = array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12101207                                'email',
    12111208                                'url',
    12121209                        ),
    1213                         'sanitize_callback'  => 'sanitize_key',
    12141210                        'type'               => 'string',
    1215                         'validate_callback'  => 'rest_validate_request_arg',
    12161211                );
    12171212
    12181213                $query_params['slug']    = array(
    12191214                        'description'        => __( 'Limit result set to resources with a specific slug.' ),
    12201215                        'type'               => 'string',
    1221                         'validate_callback'  => 'rest_validate_request_arg',
    12221216                );
    12231217
    12241218                $query_params['roles']   = array(
    12251219                        'description'        => __( 'Limit result set to resources matching at least one specific role provided. Accepts csv list or single role.' ),
    12261220                        'type'               => 'array',
    1227                         'sanitize_callback'  => 'wp_parse_slug_list',
     1221                        'items'              => array(
     1222                                'type'           => 'string',
     1223                        ),
    12281224                );
    12291225
    12301226                return $query_params;
  • tests/phpunit/tests/rest-api/rest-categories-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php
    index 440cb45..4212f5f 100644
    a b class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas 
    428428                $this->assertEquals( 'Child', $data[0]['name'] );
    429429        }
    430430
     431        public function test_get_terms_invalid_parent_arg() {
     432                $category1 = $this->factory->category->create( array( 'name' => 'Parent' ) );
     433                $this->factory->category->create( array( 'name' => 'Child', 'parent' => $category1 ) );
     434                $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
     435                $request->set_param( 'parent', 'invalid-parent' );
     436                $response = $this->server->dispatch( $request );
     437                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     438        }
     439
    431440        public function test_get_terms_private_taxonomy() {
    432441                register_taxonomy( 'robin', 'post', array( 'public' => false ) );
    433442                $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin' ) );
  • tests/phpunit/tests/rest-api/rest-comments-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php
    index 8dc8c4c..6e8c89f 100644
    a b class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    300300                $data = $response->get_data();
    301301                $this->assertEquals( 2, count( $data ) );
    302302                $this->assertEquals( $id3, $data[0]['id'] );
     303                // Orderby=>invalid should fail
     304                $request->set_param( 'orderby', 'invalid' );
     305                $response = $this->server->dispatch( $request );
     306                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     307                // fails on invalid id
     308                $request->set_param( 'orderby', array( 'include' ) );
     309                $request->set_param( 'include', array( 'invalid' ) );
     310                $response = $this->server->dispatch( $request );
     311                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    303312        }
    304313
    305314        public function test_get_items_exclude_query() {
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    320329                $data = $response->get_data();
    321330                $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    322331                $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
     332
     333                // fails on invalid id
     334                $request->set_param( 'exclude', array( 'invalid' ) );
     335                $response = $this->server->dispatch( $request );
     336                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    323337        }
    324338
    325339        public function test_get_items_offset_query() {
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    343357                $request->set_param( 'page', 3 );
    344358                $response = $this->server->dispatch( $request );
    345359                $this->assertCount( 2, $response->get_data() );
     360                // 'offset' with invalid value errors
     361                $request->set_param( 'offset', 'moreplease' );
     362                $response = $this->server->dispatch( $request );
     363                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    346364        }
    347365
    348366        public function test_get_items_order_query() {
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    364382                $response = $this->server->dispatch( $request );
    365383                $data = $response->get_data();
    366384                $this->assertEquals( self::$approved_id, $data[0]['id'] );
     385                // order=>asc,id should fail
     386                $request->set_param( 'order', 'asc,id' );
     387                $response = $this->server->dispatch( $request );
     388                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    367389        }
    368390
    369391        public function test_get_items_private_post_no_permissions() {
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    402424                $this->assertEquals( 200, $response->get_status() );
    403425                $comments = $response->get_data();
    404426                $this->assertCount( 2, $comments );
     427                // Invalid author param errors
     428                $request->set_param( 'author', 'skippy' );
     429                $response = $this->server->dispatch( $request );
     430                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    405431                // Unavailable to unauthenticated; defaults to error
    406432                wp_set_current_user( 0 );
     433                $request->set_param( 'author', array( self::$author_id, self::$subscriber_id ) );
    407434                $response = $this->server->dispatch( $request );
    408435                $this->assertErrorResponse( 'rest_forbidden_param', $response, 401 );
    409436        }
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    441468                $this->assertEquals( 200, $response->get_status() );
    442469                $comments = $response->get_data();
    443470                $this->assertCount( 2, $comments );
     471                // 'author_exclude' for both invalid author
     472                $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
     473                $request->set_param( 'author_exclude', 'skippy' );
     474                $response = $this->server->dispatch( $request );
     475                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    444476                // Unavailable to unauthenticated; defaults to error
    445477                wp_set_current_user( 0 );
     478                $request->set_param( 'author_exclude', array( self::$author_id, self::$subscriber_id ) );
    446479                $response = $this->server->dispatch( $request );
    447480                $this->assertErrorResponse( 'rest_forbidden_param', $response, 401 );
    448481        }
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    470503                $request->set_param( 'parent', array( $parent_id, $parent_id2 ) );
    471504                $response = $this->server->dispatch( $request );
    472505                $this->assertCount( 2, $response->get_data() );
     506                // Invalid parent should error
     507                $request->set_param( 'parent', 'invalid' );
     508                $response = $this->server->dispatch( $request );
     509                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    473510        }
    474511
    475512        public function test_get_items_parent_exclude_arg() {
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    495532                $request->set_param( 'parent_exclude', array( $parent_id, $parent_id2 ) );
    496533                $response = $this->server->dispatch( $request );
    497534                $this->assertCount( 3, $response->get_data() );
     535                // Invalid parent id should error
     536                $request->set_param( 'parent_exclude', 'invalid' );
     537                $response = $this->server->dispatch( $request );
     538                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    498539        }
    499540
    500541        public function test_get_items_search_query() {
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    957998                $this->assertEquals( $comment_id, $collection_data[0]['id'] );
    958999        }
    9591000
     1001        public function test_create_comment_invalid_email() {
     1002                $post_id = $this->factory->post->create();
     1003                wp_set_current_user( self::$admin_id );
     1004
     1005                $params = array(
     1006                        'post'  => $post_id,
     1007                        'author'           => self::$admin_id,
     1008                        'author_name'  => 'Comic Book Guy',
     1009                        'author_email' => 'hello:)',
     1010                        'author_url'   => 'http://androidsdungeon.com',
     1011                        'content' => 'Worst Comment Ever!',
     1012                        'date'  => '2014-11-07T10:14:25',
     1013                );
     1014
     1015                $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1016                $request->add_header( 'content-type', 'application/json' );
     1017                $request->set_body( wp_json_encode( $params ) );
     1018
     1019                $response = $this->server->dispatch( $request );
     1020                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     1021        }
     1022
    9601023        public function test_create_item_current_user() {
    9611024                $user_id = $this->factory->user->create( array(
    9621025                        'role' => 'subscriber',
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    10571120                $this->assertErrorResponse( 'rest_comment_invalid_karma', $response, 403 );
    10581121        }
    10591122
     1123        public function test_create_comment_invalid_post() {
     1124                wp_set_current_user( self::$subscriber_id );
     1125
     1126                $params = array(
     1127                        'post'             => 'some-slug',
     1128                        'author_name'  => 'Homer Jay Simpson',
     1129                        'author_email' => 'chunkylover53@aol.com',
     1130                        'author_url'   => 'http://compuglobalhypermeganet.com',
     1131                        'content'          => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
     1132                        'author'           => self::$subscriber_id,
     1133                );
     1134
     1135                $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1136                $request->add_header( 'content-type', 'application/json' );
     1137                $request->set_body( wp_json_encode( $params ) );
     1138                $response = $this->server->dispatch( $request );
     1139
     1140                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     1141        }
     1142
     1143        public function test_create_comment_karma_invalid_value() {
     1144                wp_set_current_user( self::$subscriber_id );
     1145
     1146                $params = array(
     1147                        'post'           => self::$post_id,
     1148                        'author_name'  => 'Homer Jay Simpson',
     1149                        'author_email' => 'chunkylover53@aol.com',
     1150                        'author_url'   => 'http://compuglobalhypermeganet.com',
     1151                        'content'         => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
     1152                        'author'           => self::$subscriber_id,
     1153                        'karma'         => 'themostkarmaever',
     1154                );
     1155
     1156                $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1157                $request->add_header( 'content-type', 'application/json' );
     1158                $request->set_body( wp_json_encode( $params ) );
     1159                $response = $this->server->dispatch( $request );
     1160
     1161                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     1162        }
     1163
    10601164        public function test_create_comment_status_without_permission() {
    10611165                wp_set_current_user( self::$subscriber_id );
    10621166
    class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 
    17261830                $this->assertArrayHasKey( 'post', $properties );
    17271831                $this->assertArrayHasKey( 'status', $properties );
    17281832                $this->assertArrayHasKey( 'type', $properties );
     1833
     1834                $this->assertEquals( '127.0.0.1', $properties['author_ip']['default'] );
     1835                $this->assertEquals( 0, $properties['parent']['default'] );
     1836                $this->assertEquals( 0, $properties['post']['default'] );
    17291837        }
    17301838
    17311839        public function test_get_item_schema_show_avatar() {
  • tests/phpunit/tests/rest-api/rest-pages-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php
    index 2ce9afe..a571803 100644
    a b class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    9595                $data = $response->get_data();
    9696                $this->assertEquals( 1, count( $data ) );
    9797                $this->assertEquals( $id2, $data[0]['id'] );
     98                // Invalid parent should fail
     99                $request->set_param( 'parent', 'some-slug' );
     100                $response = $this->server->dispatch( $request );
     101                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    98102        }
    99103
    100104        public function test_get_items_parents_query() {
    class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    129133                $data = $response->get_data();
    130134                $this->assertEquals( 1, count( $data ) );
    131135                $this->assertEquals( $id1, $data[0]['id'] );
     136                // Invalid parent_exclude should error
     137                $request->set_param( 'parent_exclude', 'some-slug' );
     138                $response = $this->server->dispatch( $request );
     139                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    132140        }
    133141
    134142        public function test_get_items_menu_order_query() {
    class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    156164                $this->assertEquals( $id4, $data[1]['id'] );
    157165                $this->assertEquals( $id2, $data[2]['id'] );
    158166                $this->assertEquals( $id3, $data[3]['id'] );
     167                // Invalid menu_order should fail
     168                $request = new WP_REST_Request( 'GET', '/wp/v2/pages' );
     169                $request->set_param( 'menu_order', 'top-first' );
     170                $response = $this->server->dispatch( $request );
     171                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    159172        }
    160173
    161174        public function test_get_items_min_max_pages_query() {
  • tests/phpunit/tests/rest-api/rest-posts-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
    index dcebfe8..e489667 100644
    a b class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    9292                        'author_exclude',
    9393                        'before',
    9494                        'categories',
     95                        'categories_exclude',
    9596                        'context',
    9697                        'exclude',
    9798                        'include',
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    105106                        'status',
    106107                        'sticky',
    107108                        'tags',
     109                        'tags_exclude',
    108110                        ), $keys );
    109111        }
    110112
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    183185                $this->assertEquals( 2, count( $data ) );
    184186                $this->assertNotEquals( self::$editor_id, $data[0]['author'] );
    185187                $this->assertNotEquals( self::$editor_id, $data[1]['author'] );
     188                // invalid author_exclude errors
     189                $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     190                $request->set_param( 'author_exclude', 'invalid' );
     191                $response = $this->server->dispatch( $request );
     192                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    186193        }
    187194
    188195        public function test_get_items_include_query() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    202209                $data = $response->get_data();
    203210                $this->assertEquals( 2, count( $data ) );
    204211                $this->assertEquals( $id1, $data[0]['id'] );
     212                // Invalid include should error
     213                $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     214                $request->set_param( 'include', 'invalid' );
     215                $response = $this->server->dispatch( $request );
     216                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    205217        }
    206218
    207219        public function test_get_items_exclude_query() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    224236                $data = $response->get_data();
    225237                $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    226238                $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
     239
     240                $request->set_param( 'exclude', 'invalid' );
     241                $response = $this->server->dispatch( $request );
     242                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    227243        }
    228244
    229245        public function test_get_items_search_query() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    352368                $response = $this->server->dispatch( $request );
    353369                $data = $response->get_data();
    354370                $this->assertEquals( 'Apple Cobbler', $data[0]['title']['rendered'] );
     371                // order=>asc,id should fail
     372                $request->set_param( 'order', 'asc,id' );
     373                $response = $this->server->dispatch( $request );
     374                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     375                // orderby=>content should fail (invalid param test)
     376                $request->set_param( 'order', 'asc' );
     377                $request->set_param( 'orderby', 'content' );
     378                $response = $this->server->dispatch( $request );
     379                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    355380        }
    356381
    357382        public function test_get_items_with_orderby_relevance() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    402427                $request->set_param( 'page', 3 );
    403428                $response = $this->server->dispatch( $request );
    404429                $this->assertCount( 2, $response->get_data() );
     430                // Invalid 'offset' should error
     431                $request->set_param( 'offset', 'moreplease' );
     432                $response = $this->server->dispatch( $request );
     433                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    405434        }
    406435
    407436        public function test_get_items_tags_query() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    458487
    459488                $response = $this->server->dispatch( $request );
    460489                $this->assertCount( 1, $response->get_data() );
     490
     491                $request->set_param( 'tags', array( 'my-tag' ) );
     492                $response = $this->server->dispatch( $request );
     493                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    461494        }
    462495
    463496        public function test_get_items_tags_and_categories_exclude_query() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    480513                $data = $response->get_data();
    481514                $this->assertCount( 1, $data );
    482515                $this->assertEquals( $id2, $data[0]['id'] );
     516
     517                $request->set_param( 'tags_exclude', array( 'my-tag' ) );
     518                $response = $this->server->dispatch( $request );
     519                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    483520        }
    484521
    485522        public function test_get_items_sticky_query() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    497534                $posts = $response->get_data();
    498535                $post = $posts[0];
    499536                $this->assertEquals( $id2, $post['id'] );
     537
     538                $request->set_param( 'sticky', 'nothanks' );
     539                $response = $this->server->dispatch( $request );
     540                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    500541        }
    501542
    502543        public function test_get_items_sticky_with_post__in_query() {
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    19351976                $response = $this->server->dispatch( $request );
    19361977                $data = $response->get_data();
    19371978                $properties = $data['schema']['properties'];
    1938                 $this->assertEquals( 25, count( $properties ) );
     1979                $this->assertEquals( 23, count( $properties ) );
    19391980                $this->assertArrayHasKey( 'author', $properties );
    19401981                $this->assertArrayHasKey( 'comment_status', $properties );
    19411982                $this->assertArrayHasKey( 'content', $properties );
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    19581999                $this->assertArrayHasKey( 'title', $properties );
    19592000                $this->assertArrayHasKey( 'type', $properties );
    19602001                $this->assertArrayHasKey( 'tags', $properties );
    1961                 $this->assertArrayHasKey( 'tags_exclude', $properties );
    19622002                $this->assertArrayHasKey( 'categories', $properties );
    1963                 $this->assertArrayHasKey( 'categories_exclude', $properties );
    19642003        }
    19652004
    19662005        public function test_get_additional_field_registration() {
  • tests/phpunit/tests/rest-api/rest-tags-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php
    index 0bdae85..568b15a 100644
    a b class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 
    9898                $this->assertEquals( 2, count( $data ) );
    9999                $this->assertEquals( 'Season 5', $data[0]['name'] );
    100100                $this->assertEquals( 'The Be Sharps', $data[1]['name'] );
     101                // invalid value should fail
     102                $request->set_param( 'hide_empty', 'nothanks' );
     103                $response = $this->server->dispatch( $request );
     104                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    101105        }
    102106
    103107        public function test_get_items_include_query() {
    class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 
    117121                $data = $response->get_data();
    118122                $this->assertEquals( 2, count( $data ) );
    119123                $this->assertEquals( $id3, $data[0]['id'] );
     124                // Include invalid value shoud fail
     125                $request->set_param( 'include', array( 'myterm' ) );
     126                $response = $this->server->dispatch( $request );
     127                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    120128        }
    121129
    122130        public function test_get_items_exclude_query() {
    class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 
    132140                $data = $response->get_data();
    133141                $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    134142                $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
     143                // Invalid exclude value should fail
     144                $request->set_param( 'exclude', array( 'invalid' ) );
     145                $response = $this->server->dispatch( $request );
     146                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    135147        }
    136148
    137149        public function test_get_items_offset_query() {
    class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 
    151163                $request->set_param( 'page', 3 );
    152164                $response = $this->server->dispatch( $request );
    153165                $this->assertCount( 2, $response->get_data() );
     166                // 'offset' invalid value shoudl fail
     167                $request->set_param( 'offset', 'moreplease' );
     168                $response = $this->server->dispatch( $request );
     169                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    154170        }
    155171
    156172
    class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 
    181197                $data = $response->get_data();
    182198                $this->assertEquals( 2, count( $data ) );
    183199                $this->assertEquals( 'Apple', $data[0]['name'] );
     200                // Invalid orderby should fail.
     201                $request->set_param( 'orderby', 'invalid' );
     202                $response = $this->server->dispatch( $request );
     203                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    184204        }
    185205
    186206        public function test_get_items_orderby_id() {
    class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 
    231251                $data = $response->get_data();
    232252                $this->assertEquals( 2, count( $data ) );
    233253                $this->assertEquals( 'DC', $data[0]['name'] );
     254
     255                // Invalid post should error.
     256                $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     257                $request->set_param( 'post', 'invalid-post' );
     258                $response = $this->server->dispatch( $request );
     259                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    234260        }
    235261
    236262        public function test_get_terms_post_args_paging() {
  • tests/phpunit/tests/rest-api/rest-users-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php
    index 4f89ac2..7dd2540 100644
    a b class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { 
    363363                $this->assertErrorResponse( 'rest_forbidden_orderby', $response, 401 );
    364364        }
    365365
     366        public function test_get_items_invalid_order() {
     367                $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     368                $request->set_param( 'order', 'asc,id' );
     369                $response = $this->server->dispatch( $request );
     370                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     371        }
     372
     373        public function test_get_items_invalid_orderby() {
     374                $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
     375                $request->set_param( 'orderby', 'invalid' );
     376                $response = $this->server->dispatch( $request );
     377                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     378        }
     379
    366380        public function test_get_items_offset() {
    367381                wp_set_current_user( self::$user );
    368382                // 2 users created in __construct(), plus default user
    class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { 
    379393                $request->set_param( 'page', 3 );
    380394                $response = $this->server->dispatch( $request );
    381395                $this->assertCount( 2, $response->get_data() );
     396                // 'offset' invalid value should error
     397                $request->set_param( 'offset', 'moreplease' );
     398                $response = $this->server->dispatch( $request );
     399                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    382400        }
    383401
    384402        public function test_get_items_include_query() {
    class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { 
    399417                $data = $response->get_data();
    400418                $this->assertEquals( 2, count( $data ) );
    401419                $this->assertEquals( $id3, $data[0]['id'] );
     420                // Invalid include should fail
     421                $request->set_param( 'include', 'invalid' );
     422                $response = $this->server->dispatch( $request );
     423                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    402424                // No privileges
     425                $request->set_param( 'include', array( $id3, $id1 ) );
    403426                wp_set_current_user( 0 );
    404427                $response = $this->server->dispatch( $request );
    405428                $data = $response->get_data();
    class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { 
    421444                $data = $response->get_data();
    422445                $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    423446                $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
     447                // Invalid exlude value should error.
     448                $request->set_param( 'exclude', 'none-of-those-please' );
     449                $response = $this->server->dispatch( $request );
     450                $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    424451        }
    425452
    426453        public function test_get_items_search() {