Ticket #38607: rest-base.patch
| File rest-base.patch, 5.3 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
153 153 'labels' => $post_type->labels, 154 154 'name' => $post_type->label, 155 155 'slug' => $post_type->name, 156 'rest_base' => $post_type->rest_base, 156 157 ); 157 158 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; 158 159 $data = $this->add_additional_fields_to_object( $data, $request ); … … 236 237 'context' => array( 'view', 'edit', 'embed' ), 237 238 'readonly' => true, 238 239 ), 240 'rest_base' => array( 241 'description' => __( 'REST base route for the resource.' ), 242 'type' => 'array', 243 'context' => array( 'view', 'edit', 'embed' ), 244 'readonly' => true, 245 ), 239 246 ), 240 247 ); 241 248 return $this->add_additional_fields_schema( $schema ); -
src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
187 187 'types' => $taxonomy->object_type, 188 188 'show_cloud' => $taxonomy->show_tagcloud, 189 189 'hierarchical' => $taxonomy->hierarchical, 190 'rest_base' => $taxonomy->rest_base, 190 191 ); 191 192 192 193 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; … … 282 283 'context' => array( 'view', 'edit' ), 283 284 'readonly' => true, 284 285 ), 286 'rest_base' => array( 287 'description' => __( 'REST base route for the resource.' ), 288 'type' => 'array', 289 'context' => array( 'view', 'edit', 'embed' ), 290 'readonly' => true, 291 ), 285 292 ), 286 293 ); 287 294 return $this->add_additional_fields_schema( $schema ); -
tests/phpunit/tests/rest-api/rest-post-types-controller.php
109 109 $response = $this->server->dispatch( $request ); 110 110 $data = $response->get_data(); 111 111 $properties = $data['schema']['properties']; 112 $this->assertEquals( 6, count( $properties ) );112 $this->assertEquals( 7, count( $properties ) ); 113 113 $this->assertArrayHasKey( 'capabilities', $properties ); 114 114 $this->assertArrayHasKey( 'description', $properties ); 115 115 $this->assertArrayHasKey( 'hierarchical', $properties ); … … 116 116 $this->assertArrayHasKey( 'labels', $properties ); 117 117 $this->assertArrayHasKey( 'name', $properties ); 118 118 $this->assertArrayHasKey( 'slug', $properties ); 119 $this->assertArrayHasKey( 'rest_base', $properties ); 119 120 } 120 121 121 122 public function test_get_additional_field_registration() { … … 159 160 $this->assertEquals( $post_type_obj->name, $data['slug'] ); 160 161 $this->assertEquals( $post_type_obj->description, $data['description'] ); 161 162 $this->assertEquals( $post_type_obj->hierarchical, $data['hierarchical'] ); 163 $this->assertEquals( $post_type_obj->rest_base, $data['rest_base'] ); 162 164 163 165 $links = test_rest_expand_compact_links( $links ); 164 166 $this->assertEquals( rest_url( 'wp/v2/types' ), $links['collection'][0]['href'] ); -
tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
45 45 $this->assertEquals( 'Tags', $data['post_tag']['name'] ); 46 46 $this->assertEquals( 'post_tag', $data['post_tag']['slug'] ); 47 47 $this->assertEquals( false, $data['post_tag']['hierarchical'] ); 48 $this->assertEquals( 'tags', $data['post_tag']['rest_base'] ); 48 49 } 49 50 50 51 public function test_get_items_invalid_permission_for_context() { … … 134 135 $response = $this->server->dispatch( $request ); 135 136 $data = $response->get_data(); 136 137 $properties = $data['schema']['properties']; 137 $this->assertEquals( 8, count( $properties ) );138 $this->assertEquals( 9, count( $properties ) ); 138 139 $this->assertArrayHasKey( 'capabilities', $properties ); 139 140 $this->assertArrayHasKey( 'description', $properties ); 140 141 $this->assertArrayHasKey( 'hierarchical', $properties ); … … 143 144 $this->assertArrayHasKey( 'slug', $properties ); 144 145 $this->assertArrayHasKey( 'show_cloud', $properties ); 145 146 $this->assertArrayHasKey( 'types', $properties ); 147 $this->assertArrayHasKey( 'rest_base', $properties ); 146 148 } 147 149 148 150 public function tearDown() { … … 168 170 $this->assertEquals( $tax_obj->name, $data['slug'] ); 169 171 $this->assertEquals( $tax_obj->description, $data['description'] ); 170 172 $this->assertEquals( $tax_obj->hierarchical, $data['hierarchical'] ); 173 $this->assertEquals( $tax_obj->rest_base, $data['rest_base'] ); 171 174 $this->assertEquals( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] ); 172 175 $this->assertArrayHasKey( 'https://api.w.org/items', $links ); 173 176 if ( 'edit' === $context ) {