From 8931c32237b53868db45c65ab6b88e105f9185d2 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Fri, 11 Oct 2019 13:36:04 -0300 Subject: [PATCH] add api terms test to query_params `include` --- tests/test-api-terms.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/test-api-terms.php b/tests/test-api-terms.php index f69fecfe1..29947489d 100644 --- a/tests/test-api-terms.php +++ b/tests/test-api-terms.php @@ -130,7 +130,7 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase { true ); - $this->tainacan_entity_factory->create_entity( + $term1 = $this->tainacan_entity_factory->create_entity( 'term', array( 'taxonomy' => $taxonomy->get_db_identifier(), @@ -178,6 +178,28 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase { $data = $response->get_data(); $this->assertEquals('Trap', $data['name']); + + $request = new \WP_REST_Request( + 'GET', $this->namespace . '/taxonomy/' . $taxonomy->get_id() . '/terms' + ); + $request->set_query_params([ + 'hideempty' => false, + 'include' => [$term2->get_term_id()] + ]); + $response = $this->server->dispatch($request); + $data = $response->get_data(); + $this->assertEquals(1, sizeof($data)); + + $request = new \WP_REST_Request( + 'GET', $this->namespace . '/taxonomy/' . $taxonomy->get_id() . '/terms' + ); + $request->set_query_params([ + 'hideempty' => false, + 'include' => [$term1->get_term_id(), $term2->get_term_id()] + ]); + $response = $this->server->dispatch($request); + $data = $response->get_data(); + $this->assertEquals(2, sizeof($data)); }