Changeset 40376
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
r39954 r40376 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 -
trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php
r39913 r40376 377 377 $this->assertEquals( 1, count( $data ) ); 378 378 $this->assertEquals( 'Apple', $data[0]['name'] ); 379 } 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 ); 379 413 } 380 414 -
trunk/tests/qunit/fixtures/wp-api-generated.js
r40238 r40376 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 } … … 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 }
Note: See TracChangeset
for help on using the changeset viewer.