- Timestamp:
- 04/05/2017 10:24:24 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r40106 r40378 573 573 $this->assertEquals( 1, count( $data ) ); 574 574 $this->assertEquals( $id2, $data[0]['id'] ); 575 } 576 577 public function test_get_items_slug_array_query() { 578 wp_set_current_user( self::$user ); 579 $id1 = $this->factory->user->create( array( 580 'display_name' => 'Taco', 581 'user_login' => 'taco' 582 ) ); 583 $id2 = $this->factory->user->create( array( 584 'display_name' => 'Enchilada', 585 'user_login' => 'enchilada' 586 ) ); 587 $id3 = $this->factory->user->create( array( 588 'display_name' => 'Burrito', 589 'user_login' => 'burrito' 590 ) ); 591 $this->factory->user->create( array( 592 'display_name' => 'Hon Pizza', 593 'user_login' => 'pizza' 594 ) ); 595 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 596 $request->set_param( 'slug', array( 597 'taco', 598 'burrito', 599 'enchilada', 600 ) ); 601 $request->set_param( 'orderby', 'slug' ); 602 $request->set_param( 'order', 'asc' ); 603 $response = $this->server->dispatch( $request ); 604 $this->assertEquals( 200, $response->get_status() ); 605 $data = $response->get_data(); 606 $slugs = wp_list_pluck( $data, 'slug' ); 607 $this->assertEquals( array( 'burrito', 'enchilada', 'taco' ), $slugs ); 608 } 609 610 public function test_get_items_slug_csv_query() { 611 wp_set_current_user( self::$user ); 612 $id1 = $this->factory->user->create( array( 613 'display_name' => 'Taco', 614 'user_login' => 'taco' 615 ) ); 616 $id2 = $this->factory->user->create( array( 617 'display_name' => 'Enchilada', 618 'user_login' => 'enchilada' 619 ) ); 620 $id3 = $this->factory->user->create( array( 621 'display_name' => 'Burrito', 622 'user_login' => 'burrito' 623 ) ); 624 $this->factory->user->create( array( 625 'display_name' => 'Hon Pizza', 626 'user_login' => 'pizza' 627 ) ); 628 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 629 $request->set_param( 'slug', 'taco,burrito , enchilada'); 630 $request->set_param( 'orderby', 'slug' ); 631 $request->set_param( 'order', 'desc' ); 632 $response = $this->server->dispatch( $request ); 633 $this->assertEquals( 200, $response->get_status() ); 634 $data = $response->get_data(); 635 $slugs = wp_list_pluck( $data, 'slug' ); 636 $this->assertEquals( array( 'taco', 'enchilada', 'burrito' ), $slugs ); 575 637 } 576 638
Note: See TracChangeset
for help on using the changeset viewer.