Changeset 8531 for trunk/tests/phpunit/testcases/groups/template.php
- Timestamp:
- 06/15/2014 08:00:53 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/template.php
r8419 r8531 690 690 } 691 691 } 692 693 /** 694 * @group bp_group_is_user_banned 695 */ 696 public function test_bp_group_is_user_banned_in_groups_loop() { 697 $u1 = $this->create_user(); 698 $u2 = $this->create_user(); 699 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); 700 $g2 = $this->factory->group->create( array( 'creator_id' => $u2 ) ); 701 groups_join_group( $g1, $u2 ); 702 groups_join_group( $g2, $u2 ); 703 groups_join_group( $g2, $u1 ); 704 705 // Ban user 1 from group 2 706 // Fool the admin check 707 $old_user = get_current_user_id(); 708 $this->set_current_user( $u2 ); 709 buddypress()->is_item_admin = true; 710 groups_ban_member( $u1, $g2 ); 711 712 // Start the groups loop 713 $this->set_current_user( $u1 ); 714 if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); 715 $found[] = bp_group_is_user_banned(); 716 endwhile; endif; 717 718 // Assert 719 $expected = array( 0, 1 ); 720 $this->assertEquals( $expected, $found ); 721 722 // Clean up 723 $GLOBALS['groups_template'] = null; 724 $this->set_current_user( $old_user ); 725 } 726 727 /** 728 * @group bp_group_is_user_banned 729 */ 730 public function test_bp_group_is_user_banned_not_in_groups_loop() { 731 $u1 = $this->create_user(); 732 $u2 = $this->create_user(); 733 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); 734 $g2 = $this->factory->group->create( array( 'creator_id' => $u2 ) ); 735 groups_join_group( $g1, $u2 ); 736 groups_join_group( $g2, $u2 ); 737 groups_join_group( $g2, $u1 ); 738 739 // Ban user 1 from group 2 740 // Fool the admin check 741 $old_user = get_current_user_id(); 742 $this->set_current_user( $u2 ); 743 buddypress()->is_item_admin = true; 744 groups_ban_member( $u1, $g2 ); 745 746 // Do group ban checks 747 $group1 = new BP_Groups_Group( $g1 ); 748 $group2 = new BP_Groups_Group( $g2 ); 749 750 $found = array(); 751 $found[] = bp_group_is_user_banned( $group1, $u1 ); 752 $found[] = bp_group_is_user_banned( $group2, $u1 ); 753 754 // Assert 755 $expected = array( 0, 1 ); 756 $this->assertEquals( $expected, $found ); 757 758 // Clean up 759 $this->set_current_user( $old_user ); 760 } 692 761 }
Note: See TracChangeset
for help on using the changeset viewer.