- 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-types-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/types', $routes ); 17 17 $this->assertArrayHasKey( '/wp/v2/types/(?P<type>[\w-]+)', $routes ); … … 21 21 // Collection 22 22 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/types' ); 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/types/post' ); 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/types' ); 37 $response = $this->server->dispatch( $request );37 $response = rest_get_server()->dispatch( $request ); 38 38 39 39 $data = $response->get_data(); … … 51 51 $request = new WP_REST_Request( 'GET', '/wp/v2/types' ); 52 52 $request->set_param( 'context', 'edit' ); 53 $response = $this->server->dispatch( $request );53 $response = rest_get_server()->dispatch( $request ); 54 54 $this->assertErrorResponse( 'rest_cannot_view', $response, 401 ); 55 55 } … … 57 57 public function test_get_item() { 58 58 $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); 59 $response = $this->server->dispatch( $request );59 $response = rest_get_server()->dispatch( $request ); 60 60 $this->check_post_type_object_response( 'view', $response ); 61 61 $data = $response->get_data(); … … 65 65 public function test_get_item_page() { 66 66 $request = new WP_REST_Request( 'GET', '/wp/v2/types/page' ); 67 $response = $this->server->dispatch( $request );67 $response = rest_get_server()->dispatch( $request ); 68 68 $this->check_post_type_object_response( 'view', $response, 'page' ); 69 69 $data = $response->get_data(); … … 73 73 public function test_get_item_invalid_type() { 74 74 $request = new WP_REST_Request( 'GET', '/wp/v2/types/invalid' ); 75 $response = $this->server->dispatch( $request );75 $response = rest_get_server()->dispatch( $request ); 76 76 $this->assertErrorResponse( 'rest_type_invalid', $response, 404 ); 77 77 } … … 82 82 $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); 83 83 $request->set_param( 'context', 'edit' ); 84 $response = $this->server->dispatch( $request );84 $response = rest_get_server()->dispatch( $request ); 85 85 $this->check_post_type_object_response( 'edit', $response ); 86 86 } … … 90 90 $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); 91 91 $request->set_param( 'context', 'edit' ); 92 $response = $this->server->dispatch( $request );92 $response = rest_get_server()->dispatch( $request ); 93 93 $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 ); 94 94 } … … 97 97 /** Post types can't be created */ 98 98 $request = new WP_REST_Request( 'POST', '/wp/v2/types' ); 99 $response = $this->server->dispatch( $request );99 $response = rest_get_server()->dispatch( $request ); 100 100 $this->assertEquals( 404, $response->get_status() ); 101 101 } … … 104 104 /** Post types can't be updated */ 105 105 $request = new WP_REST_Request( 'POST', '/wp/v2/types/post' ); 106 $response = $this->server->dispatch( $request );106 $response = rest_get_server()->dispatch( $request ); 107 107 $this->assertEquals( 404, $response->get_status() ); 108 108 } … … 111 111 /** Post types can't be deleted */ 112 112 $request = new WP_REST_Request( 'DELETE', '/wp/v2/types/post' ); 113 $response = $this->server->dispatch( $request );113 $response = rest_get_server()->dispatch( $request ); 114 114 $this->assertEquals( 404, $response->get_status() ); 115 115 } … … 126 126 public function test_get_item_schema() { 127 127 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/types' ); 128 $response = $this->server->dispatch( $request );128 $response = rest_get_server()->dispatch( $request ); 129 129 $data = $response->get_data(); 130 130 $properties = $data['schema']['properties']; … … 160 160 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/types/schema' ); 161 161 162 $response = $this->server->dispatch( $request );162 $response = rest_get_server()->dispatch( $request ); 163 163 $data = $response->get_data(); 164 164 … … 168 168 $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); 169 169 170 $response = $this->server->dispatch( $request );170 $response = rest_get_server()->dispatch( $request ); 171 171 $this->assertArrayHasKey( 'my_custom_int', $response->data ); 172 172
Note: See TracChangeset
for help on using the changeset viewer.