Ticket #39033: 39033.diff
File 39033.diff, 3.0 KB (added by , 8 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
149 149 $taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) ); 150 150 $taxonomies = wp_list_pluck( $taxonomies, 'name' ); 151 151 $base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name; 152 $supports = get_all_post_type_supports( $post_type->name ); 152 153 $data = array( 153 154 'capabilities' => $post_type->cap, 154 155 'description' => $post_type->description, … … 158 159 'slug' => $post_type->name, 159 160 'taxonomies' => array_values( $taxonomies ), 160 161 'rest_base' => $base, 162 'supports' => $supports, 161 163 ); 162 164 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; 163 165 $data = $this->add_additional_fields_to_object( $data, $request ); … … 254 256 'context' => array( 'view', 'edit', 'embed' ), 255 257 'readonly' => true, 256 258 ), 259 'supports' => array( 260 'description' => __( 'All features, supported by the post type.' ), 261 'type' => 'object', 262 'context' => array( 'edit' ), 263 'readonly' => true, 264 ), 257 265 ), 258 266 ); 259 267 return $this->add_additional_fields_schema( $schema ); -
tests/phpunit/tests/rest-api/rest-post-types-controller.php
119 119 $response = $this->server->dispatch( $request ); 120 120 $data = $response->get_data(); 121 121 $properties = $data['schema']['properties']; 122 $this->assertEquals( 8, count( $properties ) );122 $this->assertEquals( 9, count( $properties ) ); 123 123 $this->assertArrayHasKey( 'capabilities', $properties ); 124 124 $this->assertArrayHasKey( 'description', $properties ); 125 125 $this->assertArrayHasKey( 'hierarchical', $properties ); … … 128 128 $this->assertArrayHasKey( 'slug', $properties ); 129 129 $this->assertArrayHasKey( 'taxonomies', $properties ); 130 130 $this->assertArrayHasKey( 'rest_base', $properties ); 131 $this->assertArrayHasKey( 'supports', $properties ); 131 132 } 132 133 133 134 public function test_get_additional_field_registration() { … … 179 180 if ( 'edit' === $context ) { 180 181 $this->assertEquals( $post_type_obj->cap, $data['capabilities'] ); 181 182 $this->assertEquals( $post_type_obj->labels, $data['labels'] ); 183 $this->assertEquals( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] ); 182 184 } else { 183 185 $this->assertFalse( isset( $data['capabilities'] ) ); 184 186 $this->assertFalse( isset( $data['labels'] ) ); 187 $this->assertFalse( isset( $data['supports'] ) ); 185 188 } 186 189 } 187 190