mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
REST API: Add rest_base to response objects of wp/v2/taxonomies and wp/v2/types
Though we have the `_links.collection` available, having this value can be useful to know post type / taxonomy urls if you need to build them another way. Props youknowriad, jnylen0. Fixes #38607. git-svn-id: https://develop.svn.wordpress.org/trunk@39191 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -119,7 +119,7 @@ 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( 7, count( $properties ) );
|
||||
$this->assertEquals( 8, count( $properties ) );
|
||||
$this->assertArrayHasKey( 'capabilities', $properties );
|
||||
$this->assertArrayHasKey( 'description', $properties );
|
||||
$this->assertArrayHasKey( 'hierarchical', $properties );
|
||||
@@ -127,6 +127,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertArrayHasKey( 'name', $properties );
|
||||
$this->assertArrayHasKey( 'slug', $properties );
|
||||
$this->assertArrayHasKey( 'taxonomies', $properties );
|
||||
$this->assertArrayHasKey( 'rest_base', $properties );
|
||||
}
|
||||
|
||||
public function test_get_additional_field_registration() {
|
||||
@@ -170,6 +171,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertEquals( $post_type_obj->name, $data['slug'] );
|
||||
$this->assertEquals( $post_type_obj->description, $data['description'] );
|
||||
$this->assertEquals( $post_type_obj->hierarchical, $data['hierarchical'] );
|
||||
$this->assertEquals( $post_type_obj->rest_base, $data['rest_base'] );
|
||||
|
||||
$links = test_rest_expand_compact_links( $links );
|
||||
$this->assertEquals( rest_url( 'wp/v2/types' ), $links['collection'][0]['href'] );
|
||||
|
||||
@@ -45,6 +45,7 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertEquals( 'Tags', $data['post_tag']['name'] );
|
||||
$this->assertEquals( 'post_tag', $data['post_tag']['slug'] );
|
||||
$this->assertEquals( false, $data['post_tag']['hierarchical'] );
|
||||
$this->assertEquals( 'tags', $data['post_tag']['rest_base'] );
|
||||
}
|
||||
|
||||
public function test_get_items_invalid_permission_for_context() {
|
||||
@@ -134,7 +135,7 @@ class WP_Test_REST_Taxonomies_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 );
|
||||
@@ -143,6 +144,7 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertArrayHasKey( 'slug', $properties );
|
||||
$this->assertArrayHasKey( 'show_cloud', $properties );
|
||||
$this->assertArrayHasKey( 'types', $properties );
|
||||
$this->assertArrayHasKey( 'rest_base', $properties );
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
@@ -168,6 +170,7 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertEquals( $tax_obj->name, $data['slug'] );
|
||||
$this->assertEquals( $tax_obj->description, $data['description'] );
|
||||
$this->assertEquals( $tax_obj->hierarchical, $data['hierarchical'] );
|
||||
$this->assertEquals( $tax_obj->rest_base, $data['rest_base'] );
|
||||
$this->assertEquals( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] );
|
||||
$this->assertArrayHasKey( 'https://api.w.org/items', $links );
|
||||
if ( 'edit' === $context ) {
|
||||
|
||||
Reference in New Issue
Block a user