1 | diff --git tests/phpunit/tests/rest-api/rest-pages-controller.php tests/phpunit/tests/rest-api/rest-pages-controller.php |
---|
2 | index ee24f7af69..818b4be98c 100644 |
---|
3 | --- tests/phpunit/tests/rest-api/rest-pages-controller.php |
---|
4 | +++ tests/phpunit/tests/rest-api/rest-pages-controller.php |
---|
5 | @@ -243,7 +243,10 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te |
---|
6 | } |
---|
7 | |
---|
8 | public function test_get_item() { |
---|
9 | - |
---|
10 | + $post_id = $this->factory->post->create(array( 'post_status' => 'publish', 'post_type' => 'page' ) ); |
---|
11 | + $request = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id ); |
---|
12 | + $response = $this->server->dispatch( $request ); |
---|
13 | + $this->assertEquals( 200, $response->get_status() ); |
---|
14 | } |
---|
15 | |
---|
16 | public function test_get_item_invalid_post_type() { |
---|
17 | @@ -254,7 +257,11 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te |
---|
18 | } |
---|
19 | |
---|
20 | public function test_create_item() { |
---|
21 | + wp_set_current_user( self::$editor_id ); |
---|
22 | |
---|
23 | + $request = new WP_REST_Request( 'POST', '/wp/v2/pages' ); |
---|
24 | + $response = $this->server->dispatch( $request ); |
---|
25 | + $this->assertEquals( 201, $response->get_status() ); |
---|
26 | } |
---|
27 | |
---|
28 | public function test_create_item_with_template() { |
---|
29 | @@ -311,6 +318,21 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te |
---|
30 | } |
---|
31 | |
---|
32 | public function test_update_item() { |
---|
33 | + $page_id = $this->factory->post->create( array( |
---|
34 | + 'post_type' => 'page', |
---|
35 | + ) ); |
---|
36 | + |
---|
37 | + wp_set_current_user( self::$editor_id ); |
---|
38 | + |
---|
39 | + $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id ) ); |
---|
40 | + |
---|
41 | + $request->set_body_params( array( |
---|
42 | + 'content' => 'Lorem ipsum', |
---|
43 | + ) ); |
---|
44 | + $response = $this->server->dispatch( $request ); |
---|
45 | + |
---|
46 | + $new_data = $response->get_data(); |
---|
47 | + $this->assertEquals( 'Lorem ipsum', $new_data['content']['raw'] ); |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | diff --git tests/phpunit/tests/rest-api/rest-settings-controller.php tests/phpunit/tests/rest-api/rest-settings-controller.php |
---|
52 | index 853a013d5c..6af6ac44c8 100644 |
---|
53 | --- tests/phpunit/tests/rest-api/rest-settings-controller.php |
---|
54 | +++ tests/phpunit/tests/rest-api/rest-settings-controller.php |
---|
55 | @@ -219,6 +219,22 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase |
---|
56 | |
---|
57 | |
---|
58 | public function test_create_item() { |
---|
59 | + wp_set_current_user( self::$administrator ); |
---|
60 | + |
---|
61 | + register_setting( 'somegroup', 'new_item', array( |
---|
62 | + 'show_in_rest' => array( |
---|
63 | + 'name' => 'new_item', |
---|
64 | + ), |
---|
65 | + 'type' => 'string', |
---|
66 | + ) ); |
---|
67 | + |
---|
68 | + $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); |
---|
69 | + $request->set_param( 'new_item', 1 ); |
---|
70 | + $response = $this->server->dispatch( $request ); |
---|
71 | + $data = $response->get_data(); |
---|
72 | + |
---|
73 | + $this->assertEquals( 200, $response->get_status() ); |
---|
74 | + $this->assertEquals( 1, $data['new_item'] ); |
---|
75 | } |
---|
76 | |
---|
77 | public function test_update_item() { |
---|