|
@@ 2695-2711 (lines=17) @@
|
| 2692 |
|
); |
| 2693 |
|
} |
| 2694 |
|
|
| 2695 |
|
public function test_delete_item() |
| 2696 |
|
{ |
| 2697 |
|
wp_set_current_user(self::$admin_id); |
| 2698 |
|
|
| 2699 |
|
$comment_id = $this->factory->comment->create( |
| 2700 |
|
array( |
| 2701 |
|
'comment_approved' => 1, |
| 2702 |
|
'comment_post_ID' => self::$post_id, |
| 2703 |
|
'user_id' => self::$subscriber_id, |
| 2704 |
|
) |
| 2705 |
|
); |
| 2706 |
|
|
| 2707 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/comments/%d', $comment_id)); |
| 2708 |
|
$request->set_param('force', 'false'); |
| 2709 |
|
$response = $this->server->dispatch($request); |
| 2710 |
|
$this->assertEquals(200, $response->get_status()); |
| 2711 |
|
|
| 2712 |
|
$data = $response->get_data(); |
| 2713 |
|
$this->assertEquals('trash', $data['status']); |
| 2714 |
|
} |
|
@@ 2737-2751 (lines=15) @@
|
| 2734 |
|
$this->assertNotEmpty($data['previous']['post']); |
| 2735 |
|
} |
| 2736 |
|
|
| 2737 |
|
public function test_delete_item_already_trashed() |
| 2738 |
|
{ |
| 2739 |
|
wp_set_current_user(self::$admin_id); |
| 2740 |
|
|
| 2741 |
|
$comment_id = $this->factory->comment->create( |
| 2742 |
|
array( |
| 2743 |
|
'comment_approved' => 1, |
| 2744 |
|
'comment_post_ID' => self::$post_id, |
| 2745 |
|
'user_id' => self::$subscriber_id, |
| 2746 |
|
) |
| 2747 |
|
); |
| 2748 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/comments/%d', $comment_id)); |
| 2749 |
|
$response = $this->server->dispatch($request); |
| 2750 |
|
$this->assertEquals(200, $response->get_status()); |
| 2751 |
|
$data = $response->get_data(); |
| 2752 |
|
$response = $this->server->dispatch($request); |
| 2753 |
|
$this->assertErrorResponse('rest_already_trashed', $response, 410); |
| 2754 |
|
} |