@@ 350-368 (lines=19) @@ | ||
347 | $this->assertEquals( array( 'DC', 'Marvel', 'Image' ), $names ); |
|
348 | } |
|
349 | ||
350 | public function test_get_items_custom_tax_post_args() { |
|
351 | register_taxonomy( 'batman', 'post', array( 'show_in_rest' => true ) ); |
|
352 | $controller = new WP_REST_Terms_Controller( 'batman' ); |
|
353 | $controller->register_routes(); |
|
354 | $term1 = $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'batman' ) ); |
|
355 | $term2 = $this->factory->term->create( array( 'name' => 'Mask', 'taxonomy' => 'batman' ) ); |
|
356 | $this->factory->term->create( array( 'name' => 'Car', 'taxonomy' => 'batman' ) ); |
|
357 | $post_id = $this->factory->post->create(); |
|
358 | wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' ); |
|
359 | ||
360 | $request = new WP_REST_Request( 'GET', '/wp/v2/batman' ); |
|
361 | $request->set_param( 'post', $post_id ); |
|
362 | $response = $this->server->dispatch( $request ); |
|
363 | $this->assertEquals( 200, $response->get_status() ); |
|
364 | ||
365 | $data = $response->get_data(); |
|
366 | $this->assertEquals( 2, count( $data ) ); |
|
367 | $this->assertEquals( 'Cape', $data[0]['name'] ); |
|
368 | } |
|
369 | ||
370 | public function test_get_items_search_args() { |
|
371 | $this->factory->category->create( array( 'name' => 'Apple' ) ); |
@@ 278-296 (lines=19) @@ | ||
275 | $this->assertCount( 0, $data ); |
|
276 | } |
|
277 | ||
278 | public function test_get_items_custom_tax_post_args() { |
|
279 | register_taxonomy( 'batman', 'post', array( 'show_in_rest' => true ) ); |
|
280 | $controller = new WP_REST_Terms_Controller( 'batman' ); |
|
281 | $controller->register_routes(); |
|
282 | $term1 = $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'batman' ) ); |
|
283 | $term2 = $this->factory->term->create( array( 'name' => 'Mask', 'taxonomy' => 'batman' ) ); |
|
284 | $this->factory->term->create( array( 'name' => 'Car', 'taxonomy' => 'batman' ) ); |
|
285 | $post_id = $this->factory->post->create(); |
|
286 | wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' ); |
|
287 | ||
288 | $request = new WP_REST_Request( 'GET', '/wp/v2/batman' ); |
|
289 | $request->set_param( 'post', $post_id ); |
|
290 | $response = $this->server->dispatch( $request ); |
|
291 | $this->assertEquals( 200, $response->get_status() ); |
|
292 | ||
293 | $data = $response->get_data(); |
|
294 | $this->assertEquals( 2, count( $data ) ); |
|
295 | $this->assertEquals( 'Cape', $data[0]['name'] ); |
|
296 | } |
|
297 | ||
298 | public function test_get_items_search_args() { |
|
299 | $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) ); |