Changeset 9326 for trunk/tests/phpunit/testcases/friends/activity.php
- Timestamp:
- 01/09/2015 08:56:45 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/friends/activity.php
r9241 r9326 96 96 $this->assertTrue( count( $fd_act['activities'] ) == 0, 'friends_delete_activity() should remove "friendship_created" activities about a deleted friendship' ); 97 97 } 98 99 /** 100 * @group bp_friends_friendship_accepted_activity 101 */ 102 public function test_bp_friends_friendship_accepted_activity() { 103 $old_user = get_current_user_id(); 104 105 $u1 = $this->factory->user->create(); 106 $u2 = $this->factory->user->create(); 107 108 friends_add_friend( $u2, $u1 ); 109 $friendship_id = friends_get_friendship_id( $u2, $u1 ); 110 111 // Set current user to u1 to accepte the friendship 112 $this->set_current_user( $u1 ); 113 friends_accept_friendship( $friendship_id ); 114 115 // Reset the current user 116 $this->set_current_user( $old_user ); 117 118 $u1_act = bp_activity_get( array( 119 'component' => buddypress()->friends->id, 120 'item_id' => $friendship_id, 121 'scope' => 'just-me', 122 'filter' => array( 'action' => array( 'friendship_created' ), 'user_id' => $u1 ), 123 ) ); 124 125 $this->assertTrue( count( $u1_act['activities'] ) == 1, 'a public activity should be listed in the friend stream' ); 126 127 $u2_act = bp_activity_get( array( 128 'component' => buddypress()->friends->id, 129 'item_id' => $friendship_id, 130 'scope' => 'just-me', 131 'filter' => array( 'action' => array( 'friendship_created' ), 'user_id' => $u2 ), 132 ) ); 133 134 $this->assertTrue( count( $u2_act['activities'] ) == 1, 'a public activity should be listed in the initiator stream' ); 135 } 136 137 /** 138 * @group bp_cleanup_friendship_activities 139 */ 140 public function test_bp_cleanup_friendship_activities() { 141 $old_user = get_current_user_id(); 142 143 $u1 = $this->factory->user->create(); 144 $u2 = $this->factory->user->create(); 145 $users = array( $u1, $u2 ); 146 147 friends_add_friend( $u2, $u1 ); 148 $friendship_id = friends_get_friendship_id( $u2, $u1 ); 149 150 // Set current user to u1 to accepte the friendship and generate a public activity 151 $this->set_current_user( $u1 ); 152 friends_accept_friendship( $friendship_id ); 153 154 // Reset the current user 155 $this->set_current_user( $old_user ); 156 157 $users[] = $this->factory->user->create(); 158 $users[] = $this->factory->user->create(); 159 160 foreach( $users as $u ) { 161 bp_activity_add( array( 162 'user_id' => $u, 163 'item_id' => $friendship_id, 164 'type' => 'friendship_created', 165 'component' => buddypress()->friends->id, 166 'hide_sitewide' => true, 167 ) ); 168 } 169 170 $hidden = bp_activity_get( array( 171 'component' => buddypress()->friends->id, 172 'filter' => array( 'action' => array( 'friendship_created' ) ), 173 'show_hidden' => true, 174 ) ); 175 176 bp_cleanup_friendship_activities(); 177 178 $check = bp_activity_get( array( 179 'component' => buddypress()->friends->id, 180 'item_id' => $friendship_id, 181 'filter' => array( 'action' => array( 'friendship_created' ) ), 182 'show_hidden' => true, 183 ) ); 184 185 $this->assertTrue( count( $check['activities'] ) == 1 ); 186 } 98 187 } 99 188
Note: See TracChangeset
for help on using the changeset viewer.