Ticket #40027: 40027.4.diff
File 40027.4.diff, 5.2 KB (added by , 7 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php index 9d33eaa475..6a68ee4826 100644
class WP_REST_Terms_Controller extends WP_REST_Controller { 978 978 979 979 $query_params['slug'] = array( 980 980 'description' => __( 'Limit result set to terms with a specific slug.' ), 981 'type' => 'string', 981 'type' => 'array', 982 'items' => array( 983 'type' => 'string' 984 ), 982 985 ); 983 986 984 987 /** -
tests/phpunit/tests/rest-api/rest-categories-controller.php
diff --git tests/phpunit/tests/rest-api/rest-categories-controller.php tests/phpunit/tests/rest-api/rest-categories-controller.php index fbf7d06018..91964d69e1 100644
class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas 417 417 $this->assertEquals( 'Apple', $data[0]['name'] ); 418 418 } 419 419 420 public function test_get_items_slug_array_arg() { 421 $id1 = $this->factory->category->create( array( 'name' => 'Taco' ) ); 422 $id2 = $this->factory->category->create( array( 'name' => 'Enchilada' ) ); 423 $id3 = $this->factory->category->create( array( 'name' => 'Burrito' ) ); 424 $this->factory->category->create( array( 'name' => 'Pizza' ) ); 425 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); 426 $request->set_param( 'slug', array( 427 'taco', 428 'burrito', 429 'enchilada', 430 ) ); 431 $response = $this->server->dispatch( $request ); 432 $this->assertEquals( 200, $response->get_status() ); 433 $data = $response->get_data(); 434 $this->assertEquals( 3, count( $data ) ); 435 $this->assertEquals( 'Burrito', $data[0]['name'] ); 436 $this->assertEquals( 'Enchilada', $data[1]['name'] ); 437 $this->assertEquals( 'Taco', $data[2]['name'] ); 438 } 439 440 public function test_get_items_slug_csv_arg() { 441 $id1 = $this->factory->category->create( array( 'name' => 'Taco' ) ); 442 $id2 = $this->factory->category->create( array( 'name' => 'Enchilada' ) ); 443 $id3 = $this->factory->category->create( array( 'name' => 'Burrito' ) ); 444 $this->factory->category->create( array( 'name' => 'Pizza' ) ); 445 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); 446 $request->set_param( 'slug', 'taco, burrito, enchilada'); 447 $response = $this->server->dispatch( $request ); 448 $this->assertEquals( 200, $response->get_status() ); 449 $data = $response->get_data(); 450 $this->assertEquals( 3, count( $data ) ); 451 $this->assertEquals( 'Burrito', $data[0]['name'] ); 452 $this->assertEquals( 'Enchilada', $data[1]['name'] ); 453 $this->assertEquals( 'Taco', $data[2]['name'] ); 454 } 455 420 456 public function test_get_terms_parent_arg() { 421 457 $category1 = $this->factory->category->create( array( 'name' => 'Parent' ) ); 422 458 $this->factory->category->create( array( 'name' => 'Child', 'parent' => $category1 ) ); -
tests/phpunit/tests/rest-api/rest-tags-controller.php
diff --git tests/phpunit/tests/rest-api/rest-tags-controller.php tests/phpunit/tests/rest-api/rest-tags-controller.php index cb81b17159..11b0eb53a9 100644
class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 378 378 $this->assertEquals( 'Apple', $data[0]['name'] ); 379 379 } 380 380 381 public function test_get_items_slug_array_arg() { 382 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) ); 383 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) ); 384 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) ); 385 $this->factory->tag->create( array( 'name' => 'Pizza' ) ); 386 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); 387 $request->set_param( 'slug', array( 388 'taco', 389 'burrito', 390 'enchilada', 391 ) ); 392 $response = $this->server->dispatch( $request ); 393 $this->assertEquals( 200, $response->get_status() ); 394 $data = $response->get_data(); 395 $this->assertEquals( 3, count( $data ) ); 396 $this->assertEquals( 'Burrito', $data[0]['name'] ); 397 $this->assertEquals( 'Enchilada', $data[1]['name'] ); 398 $this->assertEquals( 'Taco', $data[2]['name'] ); 399 } 400 401 public function test_get_items_slug_csv_arg() { 402 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) ); 403 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) ); 404 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) ); 405 $this->factory->tag->create( array( 'name' => 'Pizza' ) ); 406 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); 407 $request->set_param( 'slug', 'taco, burrito, enchilada'); 408 $response = $this->server->dispatch( $request ); 409 $this->assertEquals( 200, $response->get_status() ); 410 $data = $response->get_data(); 411 $this->assertEquals( 3, count( $data ) ); 412 $this->assertEquals( 'Burrito', $data[0]['name'] ); 413 $this->assertEquals( 'Enchilada', $data[1]['name'] ); 414 $this->assertEquals( 'Taco', $data[2]['name'] ); 415 } 416 381 417 public function test_get_terms_private_taxonomy() { 382 418 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 383 419 $term1 = $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin' ) );