- Timestamp:
- 04/14/2017 08:46:22 AM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/tests/phpunit/tests/rest-api/rest-users-controller.php
r40111 r40426 583 583 $this->assertEquals( 1, count( $data ) ); 584 584 $this->assertEquals( $id2, $data[0]['id'] ); 585 } 586 587 public function test_get_items_slug_array_query() { 588 wp_set_current_user( self::$user ); 589 $id1 = $this->factory->user->create( array( 590 'display_name' => 'Taco', 591 'user_login' => 'taco' 592 ) ); 593 $id2 = $this->factory->user->create( array( 594 'display_name' => 'Enchilada', 595 'user_login' => 'enchilada' 596 ) ); 597 $id3 = $this->factory->user->create( array( 598 'display_name' => 'Burrito', 599 'user_login' => 'burrito' 600 ) ); 601 $this->factory->user->create( array( 602 'display_name' => 'Hon Pizza', 603 'user_login' => 'pizza' 604 ) ); 605 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 606 $request->set_param( 'slug', array( 607 'taco', 608 'burrito', 609 'enchilada', 610 ) ); 611 $request->set_param( 'orderby', 'slug' ); 612 $request->set_param( 'order', 'asc' ); 613 $response = $this->server->dispatch( $request ); 614 $this->assertEquals( 200, $response->get_status() ); 615 $data = $response->get_data(); 616 $slugs = wp_list_pluck( $data, 'slug' ); 617 $this->assertEquals( array( 'burrito', 'enchilada', 'taco' ), $slugs ); 618 } 619 620 public function test_get_items_slug_csv_query() { 621 wp_set_current_user( self::$user ); 622 $id1 = $this->factory->user->create( array( 623 'display_name' => 'Taco', 624 'user_login' => 'taco' 625 ) ); 626 $id2 = $this->factory->user->create( array( 627 'display_name' => 'Enchilada', 628 'user_login' => 'enchilada' 629 ) ); 630 $id3 = $this->factory->user->create( array( 631 'display_name' => 'Burrito', 632 'user_login' => 'burrito' 633 ) ); 634 $this->factory->user->create( array( 635 'display_name' => 'Hon Pizza', 636 'user_login' => 'pizza' 637 ) ); 638 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 639 $request->set_param( 'slug', 'taco,burrito , enchilada'); 640 $request->set_param( 'orderby', 'slug' ); 641 $request->set_param( 'order', 'desc' ); 642 $response = $this->server->dispatch( $request ); 643 $this->assertEquals( 200, $response->get_status() ); 644 $data = $response->get_data(); 645 $slugs = wp_list_pluck( $data, 'slug' ); 646 $this->assertEquals( array( 'taco', 'enchilada', 'burrito' ), $slugs ); 585 647 } 586 648
Note: See TracChangeset
for help on using the changeset viewer.