diff --git tests/phpunit/tests/rest-api/rest-pages-controller.php tests/phpunit/tests/rest-api/rest-pages-controller.php
index 450cd5eb00..ee24f7af69 100644
|
|
class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te |
35 | 35 | } |
36 | 36 | |
37 | 37 | public function test_register_routes() { |
38 | | |
| 38 | $routes = $this->server->get_routes(); |
| 39 | $this->assertArrayHasKey( '/wp/v2/pages', $routes ); |
| 40 | $this->assertCount( 2, $routes['/wp/v2/pages'] ); |
| 41 | $this->assertArrayHasKey( '/wp/v2/pages/(?P<id>[\d]+)', $routes ); |
| 42 | $this->assertCount( 3, $routes['/wp/v2/pages/(?P<id>[\d]+)'] ); |
39 | 43 | } |
40 | 44 | |
41 | 45 | public function test_context_param() { |
… |
… |
class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te |
83 | 87 | } |
84 | 88 | |
85 | 89 | public function test_get_items() { |
86 | | |
| 90 | $id1 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); |
| 91 | $id2 = $this->factory->post->create( array( 'post_status' => 'draft', 'post_type' => 'page' ) ); |
| 92 | $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); |
| 93 | $response = $this->server->dispatch( $request ); |
| 94 | $data = $response->get_data(); |
| 95 | $this->assertEquals( 1, count( $data ) ); |
| 96 | $this->assertEquals( $id1, $data[0]['id'] ); |
87 | 97 | } |
88 | 98 | |
89 | 99 | public function test_get_items_parent_query() { |
… |
… |
class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te |
305 | 315 | } |
306 | 316 | |
307 | 317 | public function test_delete_item() { |
| 318 | $page_id = $this->factory->post->create( array( |
| 319 | 'post_type' => 'page', |
| 320 | 'post_title' => 'Deleted page', |
| 321 | ) ); |
| 322 | wp_set_current_user( self::$editor_id ); |
308 | 323 | |
| 324 | $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/pages/%d', $page_id ) ); |
| 325 | $request->set_param( 'force', 'false' ); |
| 326 | $response = $this->server->dispatch( $request ); |
| 327 | |
| 328 | $this->assertEquals( 200, $response->get_status() ); |
| 329 | $data = $response->get_data(); |
| 330 | $this->assertEquals( 'Deleted page', $data['title']['raw'] ); |
| 331 | $this->assertEquals( 'trash', $data['status'] ); |
309 | 332 | } |
310 | 333 | |
311 | 334 | public function test_prepare_item() { |
diff --git tests/phpunit/tests/rest-api/rest-settings-controller.php tests/phpunit/tests/rest-api/rest-settings-controller.php
index 21704a035c..853a013d5c 100644
|
|
class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase |
32 | 32 | $this->assertArrayHasKey( '/wp/v2/settings', $routes ); |
33 | 33 | } |
34 | 34 | |
35 | | public function test_get_items() { |
| 35 | public function test_get_item() { |
| 36 | /** Individual settings can't be gotten **/ |
| 37 | wp_set_current_user( self::$administrator ); |
| 38 | $request = new WP_REST_Request( 'GET', '/wp/v2/settings/title' ); |
| 39 | $response = $this->server->dispatch( $request ); |
| 40 | $this->assertEquals( 404, $response->get_status() ); |
36 | 41 | } |
37 | 42 | |
38 | 43 | public function test_context_param() { |
… |
… |
class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase |
44 | 49 | $this->assertEquals( 403, $response->get_status() ); |
45 | 50 | } |
46 | 51 | |
47 | | public function test_get_item() { |
| 52 | public function test_get_items() { |
48 | 53 | wp_set_current_user( self::$administrator ); |
49 | 54 | $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); |
50 | 55 | $response = $this->server->dispatch( $request ); |
… |
… |
class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase |
336 | 341 | } |
337 | 342 | |
338 | 343 | public function test_delete_item() { |
| 344 | /** Settings can't be deleted **/ |
| 345 | $request = new WP_REST_Request( 'DELETE', '/wp/v2/settings/title' ); |
| 346 | $response = $this->server->dispatch( $request ); |
| 347 | $this->assertEquals( 404, $response->get_status() ); |
339 | 348 | } |
340 | 349 | |
341 | 350 | public function test_prepare_item() { |