- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
r41176 r42343 21 21 public function test_context_param() { 22 22 // Collection 23 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies' );24 $response = $this->server->dispatch( $request ); 25 $data = $response->get_data();23 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies' ); 24 $response = $this->server->dispatch( $request ); 25 $data = $response->get_data(); 26 26 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 27 27 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); 28 28 // Single 29 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies/post_tag' );30 $response = $this->server->dispatch( $request ); 31 $data = $response->get_data();29 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies/post_tag' ); 30 $response = $this->server->dispatch( $request ); 31 $data = $response->get_data(); 32 32 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 33 33 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); … … 35 35 36 36 public function test_get_items() { 37 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies' );38 $response = $this->server->dispatch( $request );39 $data = $response->get_data();37 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies' ); 38 $response = $this->server->dispatch( $request ); 39 $data = $response->get_data(); 40 40 $taxonomies = $this->get_public_taxonomies( get_taxonomies( '', 'objects' ) ); 41 41 $this->assertEquals( count( $taxonomies ), count( $data ) ); … … 74 74 75 75 public function test_get_item() { 76 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/category' );76 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/category' ); 77 77 $response = $this->server->dispatch( $request ); 78 78 $this->check_taxonomy_object_response( 'view', $response ); … … 97 97 98 98 public function test_get_invalid_taxonomy() { 99 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/invalid' );99 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/invalid' ); 100 100 $response = $this->server->dispatch( $request ); 101 101 $this->assertErrorResponse( 'rest_taxonomy_invalid', $response, 404 ); … … 105 105 register_taxonomy( 'api-private', 'post', array( 'public' => false ) ); 106 106 107 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/api-private' );107 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/api-private' ); 108 108 $response = $this->server->dispatch( $request ); 109 109 $this->assertErrorResponse( 'rest_forbidden', $response, 403 ); … … 111 111 112 112 public function test_create_item() { 113 /** Taxonomies can't be created * */114 $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies' );113 /** Taxonomies can't be created */ 114 $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies' ); 115 115 $response = $this->server->dispatch( $request ); 116 116 $this->assertEquals( 404, $response->get_status() ); … … 118 118 119 119 public function test_update_item() { 120 /** Taxonomies can't be updated * */121 $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies/category' );120 /** Taxonomies can't be updated */ 121 $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies/category' ); 122 122 $response = $this->server->dispatch( $request ); 123 123 $this->assertEquals( 404, $response->get_status() ); … … 125 125 126 126 public function test_delete_item() { 127 /** Taxonomies can't be deleted * */128 $request = new WP_REST_Request( 'DELETE', '/wp/v2/taxonomies/category' );127 /** Taxonomies can't be deleted */ 128 $request = new WP_REST_Request( 'DELETE', '/wp/v2/taxonomies/category' ); 129 129 $response = $this->server->dispatch( $request ); 130 130 $this->assertEquals( 404, $response->get_status() ); … … 132 132 133 133 public function test_prepare_item() { 134 $tax = get_taxonomy( 'category' );134 $tax = get_taxonomy( 'category' ); 135 135 $endpoint = new WP_REST_Taxonomies_Controller; 136 $request = new WP_REST_Request;136 $request = new WP_REST_Request; 137 137 $request->set_param( 'context', 'edit' ); 138 138 $response = $endpoint->prepare_item_for_response( $tax, $request ); … … 141 141 142 142 public function test_get_item_schema() { 143 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies' );144 $response = $this->server->dispatch( $request );145 $data = $response->get_data();143 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies' ); 144 $response = $this->server->dispatch( $request ); 145 $data = $response->get_data(); 146 146 $properties = $data['schema']['properties']; 147 147 $this->assertEquals( 9, count( $properties ) ); … … 196 196 protected function check_taxonomy_object_response( $context, $response ) { 197 197 $this->assertEquals( 200, $response->get_status() ); 198 $data = $response->get_data();198 $data = $response->get_data(); 199 199 $category = get_taxonomy( 'category' ); 200 200 $this->check_taxonomy_object( $context, $category, $data, $response->get_links() ); … … 203 203 protected function check_taxonomies_for_type_response( $type, $response ) { 204 204 $this->assertEquals( 200, $response->get_status() ); 205 $data = $response->get_data();205 $data = $response->get_data(); 206 206 $taxonomies = $this->get_public_taxonomies( get_object_taxonomies( $type, 'objects' ) ); 207 207 $this->assertEquals( count( $taxonomies ), count( $data ) );
Note: See TracChangeset
for help on using the changeset viewer.