- Timestamp:
- 04/14/2017 08:53:11 AM (9 years ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tests/phpunit/tests/rest-api/rest-tags-controller.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
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
Note: See TracChangeset
for help on using the changeset viewer.