Make WordPress Core


Ignore:
Timestamp:
10/25/2016 05:12:18 PM (10 years ago)
Author:
joehoyle
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r38832 r38911  
    239239        $this->assertEquals( 200, $response->get_status() );
    240240        $this->assertEquals( 1, count( $response->get_data() ) );
     241    }
     242
     243    public function test_get_items_invalid_status_query() {
     244        wp_set_current_user( 0 );
     245        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     246        $request->set_param( 'status', 'invalid' );
     247        $response = $this->server->dispatch( $request );
     248        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    241249    }
    242250
Note: See TracChangeset for help on using the changeset viewer.