Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions tests/phpunit/tests/rest-api/rest-autosaves-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,49 @@ public function test_create_item() {
$this->check_create_autosave_response( $response );
}

/**
* @ticket 52925
*/
public function test_create_item_invalid_integration() {
$request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' );
$request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
$params = $this->set_post_data(
array(
'id' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
)
);
$request->set_body_params( $params );

$response = rest_get_server()->dispatch( $request );
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
}

/**
* @ticket 52925
*/
public function test_create_item_invalid_unit() {
$autosaves_controller = new WP_REST_Autosaves_Controller('post');
$response = $autosaves_controller->create_item(
array(
'id' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER
)
);
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
}

/**
* @ticket 52925
*/
public function test_create_post_autosave_invalid() {
$autosaves_controller = new WP_REST_Autosaves_Controller('post');
$response = $autosaves_controller->create_post_autosave(
array(
'ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER
)
);
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
}

public function test_update_item() {
wp_set_current_user( self::$editor_id );
$request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' );
Expand Down