[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @group groups 5 */ 6 class BP_Tests_Groups_Template_BpGroupStatusMessage extends BP_UnitTestCase { 7 private $current_user; 8 private $groups_template = null; 9 10 public function setUp() { 11 parent::setUp(); 12 $this->current_user = bp_loggedin_user_id(); 13 $this->set_current_user( 0 ); 14 15 if ( isset( $GLOBALS['groups_template'] ) ) { 16 $this->groups_template = $GLOBALS['groups_template']; 17 } 18 } 19 20 public function tearDown() { 21 $this->set_current_user( $this->current_user ); 22 if ( $this->groups_template ) { 23 $GLOBALS['groups_template'] = $this->groups_template; 24 } 25 26 parent::tearDown(); 27 } 28 29 /** 30 * @group BP6319 31 */ 32 public function test_private_group_where_logged_in_user_has_not_requested_membership_but_has_been_invited() { 33 $users = self::factory()->user->create_many( 2 ); 34 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 35 36 $this->set_current_user( $users[0] ); 37 38 groups_invite_user( array( 39 'user_id' => $users[0], 40 'group_id' => $g, 41 'inviter_id' => $users[1], 42 ) ); 43 44 if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) { 45 while ( bp_groups() ) { 46 bp_the_group(); 47 $found = get_echo( 'bp_group_status_message' ); 48 } 49 } 50 51 $expected = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' ); 52 $this->assertSame( $expected, $found ); 53 } 54 55 /** 56 * @group BP6319 57 */ 58 public function test_private_group_where_logged_in_user_has_not_requested_membership_and_has_not_been_invited() { 59 $u = self::factory()->user->create(); 60 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 61 62 $this->set_current_user( $u ); 63 64 if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) { 65 while ( bp_groups() ) { 66 bp_the_group(); 67 $found = get_echo( 'bp_group_status_message' ); 68 } 69 } 70 71 $expected = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' ); 72 $this->assertSame( $expected, $found ); 73 } 74 75 /** 76 * @group BP6319 77 */ 78 public function test_private_group_visited_by_a_non_logged_in_user() { 79 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 80 81 if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) { 82 while ( bp_groups() ) { 83 bp_the_group(); 84 $found = get_echo( 'bp_group_status_message' ); 85 } 86 } 87 88 $expected = __( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' ); 89 $this->assertSame( $expected, $found ); 90 } 91 92 /** 93 * @group BP6319 94 */ 95 public function test_private_group_where_loggedin_user_has_requested_membership() { 96 $u = self::factory()->user->create(); 97 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 98 99 $this->set_current_user( $u ); 100 101 groups_send_membership_request( array( 102 'user_id' => $u, 103 'group_id' => $g 104 ) ); 105 106 if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) { 107 while ( bp_groups() ) { 108 bp_the_group(); 109 $found = get_echo( 'bp_group_status_message' ); 110 } 111 } 112 113 $expected = __( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 114 $this->assertSame( $expected, $found ); 115 } 116 117 /** 118 * @group BP6319 119 */ 120 public function test_hidden_group() { 121 $u = self::factory()->user->create(); 122 $g = self::factory()->group->create( array( 'status' => 'hidden' ) ); 123 124 $this->set_current_user( $u ); 125 126 $group = groups_get_group( $g ); 127 128 $found = get_echo( 'bp_group_status_message', array( $group ) ); 129 130 $expected = __( 'This is a hidden group and only invited members can join.', 'buddypress' ); 131 $this->assertSame( $expected, $found ); 132 } 133 134 /** 135 * @group BP6319 136 */ 137 public function test_group_parameter_should_be_obeyed() { 138 $u = self::factory()->user->create(); 139 $groups = self::factory()->group->create_many( 2, array( 'status' => 'private' ) ); 140 141 $this->set_current_user( $u ); 142 143 // Fake the current group. 144 $GLOBALS['groups_template'] = new stdClass; 145 $GLOBALS['groups_template']->group = groups_get_group( $groups[0] ); 146 147 groups_send_membership_request( array( 148 'user_id' => $u, 149 'group_id' => $groups[1] 150 ) ); 151 152 $group1 = groups_get_group( array( 153 'group_id' => $groups[1], 154 'populate_extras' => true, 155 ) ); 156 157 $found = get_echo( 'bp_group_status_message', array( $group1 ) ); 158 159 $expected = __( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 160 $this->assertSame( $expected, $found ); 161 } 162 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Jan 27 01:01:37 2021 | Cross-referenced by PHPXref 0.7.1 |