- Timestamp:
- 04/05/2017 08:24:27 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.