- Timestamp:
- 02/21/2018 04:24:30 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php
r42343 r42724 13 13 14 14 public function test_register_routes() { 15 $routes = $this->server->get_routes();15 $routes = rest_get_server()->get_routes(); 16 16 $this->assertArrayHasKey( '/wp/v2/statuses', $routes ); 17 17 $this->assertArrayHasKey( '/wp/v2/statuses/(?P<status>[\w-]+)', $routes ); … … 21 21 // Collection 22 22 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses' ); 23 $response = $this->server->dispatch( $request );23 $response = rest_get_server()->dispatch( $request ); 24 24 $data = $response->get_data(); 25 25 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); … … 27 27 // Single 28 28 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses/publish' ); 29 $response = $this->server->dispatch( $request );29 $response = rest_get_server()->dispatch( $request ); 30 30 $data = $response->get_data(); 31 31 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); … … 35 35 public function test_get_items() { 36 36 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses' ); 37 $response = $this->server->dispatch( $request );37 $response = rest_get_server()->dispatch( $request ); 38 38 39 39 $data = $response->get_data(); … … 48 48 49 49 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses' ); 50 $response = $this->server->dispatch( $request );50 $response = rest_get_server()->dispatch( $request ); 51 51 52 52 $data = $response->get_data(); … … 67 67 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses' ); 68 68 $request->set_param( 'context', 'edit' ); 69 $response = $this->server->dispatch( $request );69 $response = rest_get_server()->dispatch( $request ); 70 70 $this->assertErrorResponse( 'rest_cannot_view', $response, 401 ); 71 71 } … … 76 76 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/publish' ); 77 77 $request->set_param( 'context', 'edit' ); 78 $response = $this->server->dispatch( $request );78 $response = rest_get_server()->dispatch( $request ); 79 79 $this->check_post_status_object_response( $response ); 80 80 } … … 82 82 public function test_get_item_invalid_status() { 83 83 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/invalid' ); 84 $response = $this->server->dispatch( $request );84 $response = rest_get_server()->dispatch( $request ); 85 85 $this->assertErrorResponse( 'rest_status_invalid', $response, 404 ); 86 86 } … … 89 89 wp_set_current_user( 0 ); 90 90 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/draft' ); 91 $response = $this->server->dispatch( $request );91 $response = rest_get_server()->dispatch( $request ); 92 92 $this->assertErrorResponse( 'rest_cannot_read_status', $response, 401 ); 93 93 } … … 98 98 99 99 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/inherit' ); 100 $response = $this->server->dispatch( $request );100 $response = rest_get_server()->dispatch( $request ); 101 101 $this->assertErrorResponse( 'rest_cannot_read_status', $response, 403 ); 102 102 } … … 105 105 /** Post statuses can't be created */ 106 106 $request = new WP_REST_Request( 'POST', '/wp/v2/statuses' ); 107 $response = $this->server->dispatch( $request );107 $response = rest_get_server()->dispatch( $request ); 108 108 $this->assertEquals( 404, $response->get_status() ); 109 109 } … … 112 112 /** Post statuses can't be updated */ 113 113 $request = new WP_REST_Request( 'POST', '/wp/v2/statuses/draft' ); 114 $response = $this->server->dispatch( $request );114 $response = rest_get_server()->dispatch( $request ); 115 115 $this->assertEquals( 404, $response->get_status() ); 116 116 } … … 119 119 /** Post statuses can't be deleted */ 120 120 $request = new WP_REST_Request( 'DELETE', '/wp/v2/statuses/draft' ); 121 $response = $this->server->dispatch( $request );121 $response = rest_get_server()->dispatch( $request ); 122 122 $this->assertEquals( 404, $response->get_status() ); 123 123 } … … 134 134 public function test_get_item_schema() { 135 135 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses' ); 136 $response = $this->server->dispatch( $request );136 $response = rest_get_server()->dispatch( $request ); 137 137 $data = $response->get_data(); 138 138 $properties = $data['schema']['properties']; … … 166 166 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses' ); 167 167 168 $response = $this->server->dispatch( $request );168 $response = rest_get_server()->dispatch( $request ); 169 169 $data = $response->get_data(); 170 170 … … 174 174 $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/publish' ); 175 175 176 $response = $this->server->dispatch( $request );176 $response = rest_get_server()->dispatch( $request ); 177 177 $this->assertArrayHasKey( 'my_custom_int', $response->data ); 178 178
Note: See TracChangeset
for help on using the changeset viewer.