REST API: On comment create, return an error if the post parameter does not relate to a valid WP_Post object.

Return a `WP_Error` object for attempts to create a comment without an empty or invalid `post` ID.

Props dd32, jnylen0, rachelbaker.
Fixes #38816.

git-svn-id: https://develop.svn.wordpress.org/trunk@39288 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Rachel Baker
2016-11-18 16:55:03 +00:00
parent cceb9a6053
commit ff38fc46e4
2 changed files with 20 additions and 16 deletions

View File

@@ -1306,7 +1306,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
$request->set_body( wp_json_encode( $params ) );
$response = $this->server->dispatch( $request );
$this->assertEquals( 201, $response->get_status() );
$this->assertErrorResponse( 'rest_comment_invalid_post_id', $response, 403 );
}
public function test_create_comment_no_post_id_no_permission() {