|
@@ 870-885 (lines=16) @@
|
| 867 |
|
$this->assertContains('<' . $next_link . '>; rel="next"', $headers['Link']); |
| 868 |
|
} |
| 869 |
|
|
| 870 |
|
public function test_get_items_private_status_query_var() |
| 871 |
|
{ |
| 872 |
|
// Private query vars inaccessible to unauthorized users |
| 873 |
|
wp_set_current_user(0); |
| 874 |
|
$draft_id = $this->factory->post->create(array( 'post_status' => 'draft' )); |
| 875 |
|
$request = new WP_REST_Request('GET', '/wp/v2/posts'); |
| 876 |
|
$request->set_param('status', 'draft'); |
| 877 |
|
$response = $this->server->dispatch($request); |
| 878 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 879 |
|
|
| 880 |
|
// But they are accessible to authorized users |
| 881 |
|
wp_set_current_user(self::$editor_id); |
| 882 |
|
$response = $this->server->dispatch($request); |
| 883 |
|
$data = $response->get_data(); |
| 884 |
|
$this->assertCount(1, $data); |
| 885 |
|
$this->assertEquals($draft_id, $data[0]['id']); |
| 886 |
|
} |
| 887 |
|
|
| 888 |
|
public function test_get_items_invalid_per_page() |
|
@@ 2783-2796 (lines=14) @@
|
| 2780 |
|
); |
| 2781 |
|
} |
| 2782 |
|
|
| 2783 |
|
public function test_delete_item() |
| 2784 |
|
{ |
| 2785 |
|
$post_id = $this->factory->post->create(array( 'post_title' => 'Deleted post' )); |
| 2786 |
|
wp_set_current_user(self::$editor_id); |
| 2787 |
|
|
| 2788 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/posts/%d', $post_id)); |
| 2789 |
|
$request->set_param('force', 'false'); |
| 2790 |
|
$response = $this->server->dispatch($request); |
| 2791 |
|
|
| 2792 |
|
$this->assertNotInstanceOf('WP_Error', $response); |
| 2793 |
|
$this->assertEquals(200, $response->get_status()); |
| 2794 |
|
$data = $response->get_data(); |
| 2795 |
|
$this->assertEquals('Deleted post', $data['title']['raw']); |
| 2796 |
|
$this->assertEquals('trash', $data['status']); |
| 2797 |
|
} |
| 2798 |
|
|
| 2799 |
|
public function test_delete_item_skip_trash() |