REST API: Add the supports property to the Post Type response object.

Includes a new `supports` property in the response object and schema for the `/types` endpoints for users with the `edit_posts` capability for the given post type. The `supports` property returns an object of the features the given post type *supports*.

Props timmydcrawford, tyxla.
Fixes #39033.


git-svn-id: https://develop.svn.wordpress.org/trunk@39647 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Rachel Baker
2016-12-29 17:27:37 +00:00
parent e0531dcaa3
commit fa3f97449e
2 changed files with 13 additions and 1 deletions

View File

@@ -119,13 +119,14 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas
$response = $this->server->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
$this->assertEquals( 8, count( $properties ) );
$this->assertEquals( 9, count( $properties ) );
$this->assertArrayHasKey( 'capabilities', $properties );
$this->assertArrayHasKey( 'description', $properties );
$this->assertArrayHasKey( 'hierarchical', $properties );
$this->assertArrayHasKey( 'labels', $properties );
$this->assertArrayHasKey( 'name', $properties );
$this->assertArrayHasKey( 'slug', $properties );
$this->assertArrayHasKey( 'supports', $properties );
$this->assertArrayHasKey( 'taxonomies', $properties );
$this->assertArrayHasKey( 'rest_base', $properties );
}
@@ -179,9 +180,11 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas
if ( 'edit' === $context ) {
$this->assertEquals( $post_type_obj->cap, $data['capabilities'] );
$this->assertEquals( $post_type_obj->labels, $data['labels'] );
$this->assertEquals( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] );
} else {
$this->assertFalse( isset( $data['capabilities'] ) );
$this->assertFalse( isset( $data['labels'] ) );
$this->assertFalse( isset( $data['supports'] ) );
}
}