Changeset 32207 for trunk/tests/phpunit/tests/user/query.php
- Timestamp:
- 04/20/2015 03:15:14 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/query.php
r32001 r32207 626 626 $this->assertSame( array( 'author' => true ), $user->caps ); 627 627 } 628 629 /** 630 * @ticket 32019 631 */ 632 public function test_who_authors() { 633 if ( ! is_multisite() ) { 634 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 635 } 636 637 $b = $this->factory->blog->create(); 638 $users = $this->factory->user->create_many( 3 ); 639 640 add_user_to_blog( $b, $users[0], 'subscriber' ); 641 add_user_to_blog( $b, $users[1], 'author' ); 642 add_user_to_blog( $b, $users[2], 'editor' ); 643 644 $q = new WP_User_Query( array( 645 'who' => 'authors', 646 'blog_id' => $b, 647 ) ); 648 649 $found = wp_list_pluck( $q->get_results(), 'ID' ); 650 651 $this->assertNotContains( $users[0], $found ); 652 $this->assertContains( $users[1], $found ); 653 $this->assertContains( $users[2], $found ); 654 } 655 656 /** 657 * @ticket 32019 658 */ 659 public function test_who_authors_should_work_alongside_meta_query() { 660 if ( ! is_multisite() ) { 661 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 662 } 663 664 $b = $this->factory->blog->create(); 665 $users = $this->factory->user->create_many( 3 ); 666 667 add_user_to_blog( $b, $users[0], 'subscriber' ); 668 add_user_to_blog( $b, $users[1], 'author' ); 669 add_user_to_blog( $b, $users[2], 'editor' ); 670 671 add_user_meta( $users[1], 'foo', 'bar' ); 672 add_user_meta( $users[2], 'foo', 'baz' ); 673 674 $q = new WP_User_Query( array( 675 'who' => 'authors', 676 'blog_id' => $b, 677 'meta_query' => array( 678 'key' => 'foo', 679 'value' => 'bar', 680 ), 681 ) ); 682 683 $found = wp_list_pluck( $q->get_results(), 'ID' ); 684 685 $this->assertNotContains( $users[0], $found ); 686 $this->assertContains( $users[1], $found ); 687 $this->assertNotContains( $users[2], $found ); 688 } 628 689 }
Note: See TracChangeset
for help on using the changeset viewer.