mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
REST API: Modify the structure of our DELETE responses to be more explicit.
Add the `deleted` property to the root of the Response object to communicate if the delete action was successful. Move the state of the resource prior to the delete request under a new `previous` property. As a result DELETE responses are now structured like so:
`{ deleted: true, previous: { ... } }`
Also includes helpful information to DELETE requests for resources that are not trashable.
Props timmydcrawford, rmccue, jnylen0.
Fixes #38494.
git-svn-id: https://develop.svn.wordpress.org/trunk@39126 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1888,12 +1888,14 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
'comment_post_ID' => self::$post_id,
|
||||
'user_id' => self::$subscriber_id,
|
||||
));
|
||||
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
|
||||
|
||||
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
|
||||
$request->set_param( 'force', 'false' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( self::$post_id, $data['post'] );
|
||||
$this->assertEquals( 'trash', $data['status'] );
|
||||
}
|
||||
|
||||
public function test_delete_item_skip_trash() {
|
||||
@@ -1910,7 +1912,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( self::$post_id, $data['post'] );
|
||||
$this->assertTrue( $data['deleted'] );
|
||||
$this->assertNotEmpty( $data['previous']['post'] );
|
||||
}
|
||||
|
||||
public function test_delete_item_already_trashed() {
|
||||
|
||||
Reference in New Issue
Block a user