|
@@ 1368-1385 (lines=18) @@
|
| 1365 |
|
$this->assertErrorResponse('rest_cannot_create', $response, 401); |
| 1366 |
|
} |
| 1367 |
|
|
| 1368 |
|
public function test_create_post_draft() |
| 1369 |
|
{ |
| 1370 |
|
wp_set_current_user(self::$editor_id); |
| 1371 |
|
|
| 1372 |
|
$request = new WP_REST_Request('POST', '/wp/v2/posts'); |
| 1373 |
|
$params = $this->set_post_data( |
| 1374 |
|
array( |
| 1375 |
|
'status' => 'draft', |
| 1376 |
|
) |
| 1377 |
|
); |
| 1378 |
|
$request->set_body_params($params); |
| 1379 |
|
$response = $this->server->dispatch($request); |
| 1380 |
|
|
| 1381 |
|
$data = $response->get_data(); |
| 1382 |
|
$new_post = get_post($data['id']); |
| 1383 |
|
$this->assertEquals('draft', $data['status']); |
| 1384 |
|
$this->assertEquals('draft', $new_post->post_status); |
| 1385 |
|
// Confirm dates are null |
| 1386 |
|
$this->assertNull($data['date_gmt']); |
| 1387 |
|
$this->assertNull($data['modified_gmt']); |
| 1388 |
|
} |
|
@@ 2799-2812 (lines=14) @@
|
| 2796 |
|
$this->assertEquals('trash', $data['status']); |
| 2797 |
|
} |
| 2798 |
|
|
| 2799 |
|
public function test_delete_item_skip_trash() |
| 2800 |
|
{ |
| 2801 |
|
$post_id = $this->factory->post->create(array( 'post_title' => 'Deleted post' )); |
| 2802 |
|
wp_set_current_user(self::$editor_id); |
| 2803 |
|
|
| 2804 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/posts/%d', $post_id)); |
| 2805 |
|
$request['force'] = true; |
| 2806 |
|
$response = $this->server->dispatch($request); |
| 2807 |
|
|
| 2808 |
|
$this->assertNotInstanceOf('WP_Error', $response); |
| 2809 |
|
$this->assertEquals(200, $response->get_status()); |
| 2810 |
|
$data = $response->get_data(); |
| 2811 |
|
$this->assertTrue($data['deleted']); |
| 2812 |
|
$this->assertNotEmpty($data['previous']); |
| 2813 |
|
} |
| 2814 |
|
|
| 2815 |
|
public function test_delete_item_already_trashed() |