Changeset 40427
- Timestamp:
- 04/14/2017 08:53:11 AM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
r39957 r40427 980 980 $query_params['slug'] = array( 981 981 'description' => __( 'Limit result set to terms with a specific slug.' ), 982 'type' => 'string', 982 'type' => 'array', 983 'items' => array( 984 'type' => 'string' 985 ), 983 986 ); 984 987 -
branches/4.7/tests/phpunit/tests/rest-api/rest-tags-controller.php
r39372 r40427 375 375 $this->assertEquals( 1, count( $data ) ); 376 376 $this->assertEquals( 'Apple', $data[0]['name'] ); 377 } 378 379 public function test_get_items_slug_array_arg() { 380 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) ); 381 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) ); 382 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) ); 383 $this->factory->tag->create( array( 'name' => 'Pizza' ) ); 384 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); 385 $request->set_param( 'slug', array( 386 'taco', 387 'burrito', 388 'enchilada', 389 ) ); 390 $response = $this->server->dispatch( $request ); 391 $this->assertEquals( 200, $response->get_status() ); 392 $data = $response->get_data(); 393 $names = wp_list_pluck( $data, 'name' ); 394 sort( $names ); 395 $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); 396 } 397 398 public function test_get_items_slug_csv_arg() { 399 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) ); 400 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) ); 401 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) ); 402 $this->factory->tag->create( array( 'name' => 'Pizza' ) ); 403 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); 404 $request->set_param( 'slug', 'taco,burrito, enchilada'); 405 $response = $this->server->dispatch( $request ); 406 $this->assertEquals( 200, $response->get_status() ); 407 $data = $response->get_data(); 408 $names = wp_list_pluck( $data, 'name' ); 409 sort( $names ); 410 $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); 377 411 } 378 412 -
branches/4.7/tests/qunit/fixtures/wp-api-generated.js
r40426 r40427 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.