mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 18:54:29 +00:00
REST API: Return an error if the page number is out of bounds.
Return an error from the REST API if a page number larger than the total pages count is requested. Props morganestes. Fixes #39061. git-svn-id: https://develop.svn.wordpress.org/trunk@39967 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -827,6 +827,17 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 39061
|
||||
*/
|
||||
public function test_get_items_invalid_max_pages() {
|
||||
// Out of bounds
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
|
||||
$request->set_param( 'page', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertErrorResponse( 'rest_post_invalid_page_number', $response, 400 );
|
||||
}
|
||||
|
||||
public function test_get_items_invalid_context() {
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
|
||||
$request->set_param( 'context', 'banana' );
|
||||
|
||||
Reference in New Issue
Block a user