add api terms test to query_params `include`
This commit is contained in:
parent
6d10cf31d5
commit
8931c32237
|
@ -130,7 +130,7 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->tainacan_entity_factory->create_entity(
|
$term1 = $this->tainacan_entity_factory->create_entity(
|
||||||
'term',
|
'term',
|
||||||
array(
|
array(
|
||||||
'taxonomy' => $taxonomy->get_db_identifier(),
|
'taxonomy' => $taxonomy->get_db_identifier(),
|
||||||
|
@ -178,6 +178,28 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals('Trap', $data['name']);
|
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue