REST API: Validate posts status enum

Currently we are using a different validate callback, so the `enum` is not interpretted. We just have to fallback to the result of `rest_validate_request_arg` in our custom wrapper function.

Fixes #38417.


git-svn-id: https://develop.svn.wordpress.org/trunk@38911 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Hoyle
2016-10-25 17:12:18 +00:00
parent 57aec4798f
commit 6d8e277152
2 changed files with 10 additions and 2 deletions
@@ -240,6 +240,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$this->assertEquals( 1, count( $response->get_data() ) );
}
public function test_get_items_invalid_status_query() {
wp_set_current_user( 0 );
$request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
$request->set_param( 'status', 'invalid' );
$response = $this->server->dispatch( $request );
$this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
}
public function test_get_items_status_without_permissions() {
$draft_id = $this->factory->post->create( array(
'post_status' => 'draft',