Ticket #40027: 40027.5.diff
File 40027.5.diff, 4.0 KB (added by , 7 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php index 9d33eaa..1a31630 100644
a b 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-tags-controller.php
diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php index cb81b17..fccc4d7 100644
a b 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 $names = wp_list_pluck( $data, 'name' ); 396 sort( $names ); 397 $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); 398 } 399 400 public function test_get_items_slug_csv_arg() { 401 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) ); 402 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) ); 403 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) ); 404 $this->factory->tag->create( array( 'name' => 'Pizza' ) ); 405 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); 406 $request->set_param( 'slug', 'taco,burrito, enchilada'); 407 $response = $this->server->dispatch( $request ); 408 $this->assertEquals( 200, $response->get_status() ); 409 $data = $response->get_data(); 410 $names = wp_list_pluck( $data, 'name' ); 411 sort( $names ); 412 $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); 413 } 414 381 415 public function test_get_terms_private_taxonomy() { 382 416 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 383 417 $term1 = $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin' ) ); -
tests/qunit/fixtures/wp-api-generated.js
diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index b4c6109..2e47935 100644
a b mockedApiResponse.Schema = { 1990 1990 "slug": { 1991 1991 "required": false, 1992 1992 "description": "Limit result set to terms with a specific slug.", 1993 "type": "string" 1993 "type": "array", 1994 "items": { 1995 "type": "string" 1996 } 1994 1997 } 1995 1998 } 1996 1999 }, … … mockedApiResponse.Schema = { 2225 2228 "slug": { 2226 2229 "required": false, 2227 2230 "description": "Limit result set to terms with a specific slug.", 2228 "type": "string" 2231 "type": "array", 2232 "items": { 2233 "type": "string" 2234 } 2229 2235 } 2230 2236 } 2231 2237 },