Changeset 7938 for trunk/tests/testcases/groups/class-bp-groups-group.php
- Timestamp:
- 02/20/2014 03:14:13 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/testcases/groups/class-bp-groups-group.php
r7573 r7938 642 642 $this->assertEquals( array( $g1 ), $found ); 643 643 } 644 645 /** 646 * @group get_group_extras 647 */ 648 public function test_get_group_extras_non_logged_in() { 649 $paged_groups = array(); 650 $paged_groups[] = new stdClass; 651 $paged_groups[] = new stdClass; 652 653 $paged_groups[0]->id = 5; 654 $paged_groups[1]->id = 10; 655 656 $group_ids = array( 5, 10 ); 657 658 $expected = array(); 659 foreach ( $paged_groups as $key => $value ) { 660 $expected[ $key ] = new stdClass; 661 $expected[ $key ]->id = $value->id; 662 $expected[ $key ]->is_member = '0'; 663 $expected[ $key ]->is_invited = '0'; 664 $expected[ $key ]->is_pending = '0'; 665 $expected[ $key ]->is_banned = false; 666 } 667 668 $old_user = get_current_user_id(); 669 $this->set_current_user( 0 ); 670 671 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 672 673 $this->set_current_user( $old_user ); 674 } 675 676 /** 677 * @group get_group_extras 678 */ 679 public function test_get_group_extras_non_member() { 680 $u = $this->create_user(); 681 $g = $this->factory->group->create(); 682 683 $paged_groups = array(); 684 $paged_groups[] = new stdClass; 685 $paged_groups[0]->id = $g; 686 687 $group_ids = array( $g ); 688 689 $expected = array(); 690 foreach ( $paged_groups as $key => $value ) { 691 $expected[ $key ] = new stdClass; 692 $expected[ $key ]->id = $value->id; 693 $expected[ $key ]->is_member = '0'; 694 $expected[ $key ]->is_invited = '0'; 695 $expected[ $key ]->is_pending = '0'; 696 $expected[ $key ]->is_banned = false; 697 } 698 699 $old_user = get_current_user_id(); 700 $this->set_current_user( $u ); 701 702 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 703 704 $this->set_current_user( $old_user ); 705 } 706 707 /** 708 * @group get_group_extras 709 */ 710 public function test_get_group_extras_member() { 711 $u = $this->create_user(); 712 $g = $this->factory->group->create(); 713 $this->add_user_to_group( $u, $g ); 714 715 $paged_groups = array(); 716 $paged_groups[] = new stdClass; 717 $paged_groups[0]->id = $g; 718 719 $group_ids = array( $g ); 720 721 $expected = array(); 722 foreach ( $paged_groups as $key => $value ) { 723 $expected[ $key ] = new stdClass; 724 $expected[ $key ]->id = $value->id; 725 $expected[ $key ]->is_member = '1'; 726 $expected[ $key ]->is_invited = '0'; 727 $expected[ $key ]->is_pending = '0'; 728 $expected[ $key ]->is_banned = false; 729 } 730 731 $old_user = get_current_user_id(); 732 $this->set_current_user( $u ); 733 734 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 735 736 $this->set_current_user( $old_user ); 737 } 738 739 /** 740 * @group get_group_extras 741 */ 742 public function test_get_group_extras_invited() { 743 $u = $this->create_user(); 744 $g = $this->factory->group->create(); 745 746 $invite = new BP_Groups_Member; 747 $invite->group_id = $g; 748 $invite->user_id = $u; 749 $invite->date_modified = bp_core_current_time(); 750 $invite->invite_sent = true; 751 $invite->is_confirmed = false; 752 $invite->save(); 753 754 $paged_groups = array(); 755 $paged_groups[] = new stdClass; 756 $paged_groups[0]->id = $g; 757 758 $group_ids = array( $g ); 759 760 $expected = array(); 761 foreach ( $paged_groups as $key => $value ) { 762 $expected[ $key ] = new stdClass; 763 $expected[ $key ]->id = $value->id; 764 $expected[ $key ]->is_member = '0'; 765 $expected[ $key ]->is_invited = '1'; 766 $expected[ $key ]->is_pending = '0'; 767 $expected[ $key ]->is_banned = false; 768 } 769 770 $old_user = get_current_user_id(); 771 $this->set_current_user( $u ); 772 773 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 774 775 $this->set_current_user( $old_user ); 776 } 777 778 /** 779 * @group get_group_extras 780 */ 781 public function test_get_group_extras_pending() { 782 $u = $this->create_user(); 783 $g = $this->factory->group->create(); 784 785 $invite = new BP_Groups_Member; 786 $invite->group_id = $g; 787 $invite->user_id = $u; 788 $invite->date_modified = bp_core_current_time(); 789 $invite->invite_sent = false; 790 $invite->is_confirmed = false; 791 $invite->save(); 792 793 $paged_groups = array(); 794 $paged_groups[] = new stdClass; 795 $paged_groups[0]->id = $g; 796 797 $group_ids = array( $g ); 798 799 $expected = array(); 800 foreach ( $paged_groups as $key => $value ) { 801 $expected[ $key ] = new stdClass; 802 $expected[ $key ]->id = $value->id; 803 $expected[ $key ]->is_member = '0'; 804 $expected[ $key ]->is_invited = '0'; 805 $expected[ $key ]->is_pending = '1'; 806 $expected[ $key ]->is_banned = false; 807 } 808 809 $old_user = get_current_user_id(); 810 $this->set_current_user( $u ); 811 812 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 813 814 $this->set_current_user( $old_user ); 815 } 816 817 /** 818 * @group get_group_extras 819 */ 820 public function test_get_group_extras_banned() { 821 $u = $this->create_user(); 822 $g = $this->factory->group->create(); 823 824 $member = new BP_Groups_Member; 825 $member->group_id = $g; 826 $member->user_id = $u; 827 $member->date_modified = bp_core_current_time(); 828 $member->is_banned = true; 829 $member->save(); 830 831 $paged_groups = array(); 832 $paged_groups[] = new stdClass; 833 $paged_groups[0]->id = $g; 834 835 $group_ids = array( $g ); 836 837 $expected = array(); 838 foreach ( $paged_groups as $key => $value ) { 839 $expected[ $key ] = new stdClass; 840 $expected[ $key ]->id = $value->id; 841 $expected[ $key ]->is_member = '0'; 842 $expected[ $key ]->is_invited = '0'; 843 $expected[ $key ]->is_pending = '0'; 844 $expected[ $key ]->is_banned = true; 845 } 846 847 $old_user = get_current_user_id(); 848 $this->set_current_user( $u ); 849 850 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 851 852 $this->set_current_user( $old_user ); 853 } 644 854 } 645 855
Note: See TracChangeset
for help on using the changeset viewer.