mirror of
git://develop.git.wordpress.org/
synced 2025-03-15 09:29:48 +01:00
Tests: Improve REST API tests for categories and tags.
Props birgire, SergeyBiryukov. See #39122. Fixes #45077. git-svn-id: https://develop.svn.wordpress.org/trunk@44510 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0137c23f8d
commit
ec7687b1d9
@ -690,6 +690,9 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->check_get_taxonomy_term_response( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 39122
|
||||
*/
|
||||
public function test_get_item_meta() {
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/categories/1' );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
@ -698,24 +701,26 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
|
||||
|
||||
$meta = (array) $data['meta'];
|
||||
$this->assertArrayHasKey( 'test_single', $meta );
|
||||
$this->assertEquals( $meta['test_single'], '' );
|
||||
$this->assertSame( $meta['test_single'], '' );
|
||||
$this->assertArrayHasKey( 'test_multi', $meta );
|
||||
$this->assertEquals( $meta['test_multi'], array() );
|
||||
$this->assertSame( $meta['test_multi'], array() );
|
||||
$this->assertArrayHasKey( 'test_cat_single', $meta );
|
||||
$this->assertEquals( $meta['test_cat_single'], '' );
|
||||
$this->assertSame( $meta['test_cat_single'], '' );
|
||||
$this->assertArrayHasKey( 'test_cat_multi', $meta );
|
||||
$this->assertEquals( $meta['test_cat_multi'], array() );
|
||||
$this->assertSame( $meta['test_cat_multi'], array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 39122
|
||||
*/
|
||||
public function test_get_item_meta_registered_for_different_taxonomy() {
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/categories/1' );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertArrayHasKey( 'meta', $data );
|
||||
$this->assertArrayHasKey( 'meta', $data );
|
||||
|
||||
$meta = (array) $data['meta'];
|
||||
$this->assertEquals( false, isset( $meta['test_tag_meta'] ) );
|
||||
$this->assertFalse( isset( $meta['test_tag_meta'] ) );
|
||||
}
|
||||
|
||||
public function test_get_term_invalid_taxonomy() {
|
||||
|
@ -629,6 +629,9 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$this->check_get_taxonomy_term_response( $response, $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 39122
|
||||
*/
|
||||
public function test_get_item_meta() {
|
||||
$id = $this->factory->tag->create();
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
|
||||
@ -638,15 +641,18 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
|
||||
$meta = (array) $data['meta'];
|
||||
$this->assertArrayHasKey( 'test_single', $meta );
|
||||
$this->assertEquals( $meta['test_single'], '' );
|
||||
$this->assertSame( $meta['test_single'], '' );
|
||||
$this->assertArrayHasKey( 'test_multi', $meta );
|
||||
$this->assertEquals( $meta['test_multi'], array() );
|
||||
$this->assertSame( $meta['test_multi'], array() );
|
||||
$this->assertArrayHasKey( 'test_tag_single', $meta );
|
||||
$this->assertEquals( $meta['test_tag_single'], '' );
|
||||
$this->assertSame( $meta['test_tag_single'], '' );
|
||||
$this->assertArrayHasKey( 'test_tag_multi', $meta );
|
||||
$this->assertEquals( $meta['test_tag_multi'], array() );
|
||||
$this->assertSame( $meta['test_tag_multi'], array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 39122
|
||||
*/
|
||||
public function test_get_item_meta_registered_for_different_taxonomy() {
|
||||
$id = $this->factory->tag->create();
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
|
||||
@ -655,7 +661,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$this->assertArrayHasKey( 'meta', $data );
|
||||
|
||||
$meta = (array) $data['meta'];
|
||||
$this->assertEquals( false, isset( $meta['test_cat_meta'] ) );
|
||||
$this->assertFalse( isset( $meta['test_cat_meta'] ) );
|
||||
}
|
||||
|
||||
public function test_get_term_invalid_term() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user