@@ 79-91 (lines=13) @@ | ||
76 | $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 ); |
|
77 | } |
|
78 | ||
79 | public function test_get_items_hide_empty_arg() { |
|
80 | $post_id = $this->factory->post->create(); |
|
81 | $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) ); |
|
82 | $category2 = $this->factory->category->create( array( 'name' => 'The Be Sharps' ) ); |
|
83 | wp_set_object_terms( $post_id, array( $category1, $category2 ), 'category' ); |
|
84 | $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); |
|
85 | $request->set_param( 'hide_empty', true ); |
|
86 | $response = $this->server->dispatch( $request ); |
|
87 | $data = $response->get_data(); |
|
88 | $this->assertEquals( 2, count( $data ) ); |
|
89 | $this->assertEquals( 'Season 5', $data[0]['name'] ); |
|
90 | $this->assertEquals( 'The Be Sharps', $data[1]['name'] ); |
|
91 | } |
|
92 | ||
93 | public function test_get_items_parent_zero_arg() { |
|
94 | $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) ); |
@@ 80-92 (lines=13) @@ | ||
77 | $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 ); |
|
78 | } |
|
79 | ||
80 | public function test_get_items_hide_empty_arg() { |
|
81 | $post_id = $this->factory->post->create(); |
|
82 | $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) ); |
|
83 | $tag2 = $this->factory->tag->create( array( 'name' => 'The Be Sharps' ) ); |
|
84 | wp_set_object_terms( $post_id, array( $tag1, $tag2 ), 'post_tag' ); |
|
85 | $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); |
|
86 | $request->set_param( 'hide_empty', true ); |
|
87 | $response = $this->server->dispatch( $request ); |
|
88 | $data = $response->get_data(); |
|
89 | $this->assertEquals( 2, count( $data ) ); |
|
90 | $this->assertEquals( 'Season 5', $data[0]['name'] ); |
|
91 | $this->assertEquals( 'The Be Sharps', $data[1]['name'] ); |
|
92 | } |
|
93 | ||
94 | public function test_get_items_include_query() { |
|
95 | $id1 = $this->factory->tag->create(); |