Skip to content

Commit ffdef39

Browse files
committed
Tests: Assert unsupported autosave deletion requests.
Replace the empty delete test stub with an assertion that `DELETE` returns `rest_no_route`. First verify that the editor can retrieve the existing autosave through the same item route. Developed in: #14151 Props shailu25. See #66073. git-svn-id: https://develop.svn.wordpress.org/trunk@64290 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d7640ec commit ffdef39

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎tests/phpunit/tests/rest-api/rest-autosaves-controller.php‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,22 @@ public function test_get_item_invalid_parent_post_type( $method ) {
375375
}
376376

377377
/**
378-
* @doesNotPerformAssertions
378+
* Autosaves item route is not deletable; delete requests should not match a route.
379+
*
380+
* @ticket 66073
379381
*/
380382
public function test_delete_item() {
381-
// Controller does not implement delete_item().
383+
wp_set_current_user( self::$editor_id );
384+
385+
$route = '/wp/v2/posts/' . self::$post_id . '/autosaves/' . self::$autosave_post_id;
386+
387+
$response = rest_get_server()->dispatch( new WP_REST_Request( 'GET', $route ) );
388+
$this->assertSame( 200, $response->get_status() );
389+
390+
$request = new WP_REST_Request( 'DELETE', $route );
391+
$response = rest_get_server()->dispatch( $request );
392+
393+
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
382394
}
383395

384396
public function test_prepare_item() {

0 commit comments

Comments
 (0)