Changeset 9173
- Timestamp:
- 11/25/2014 02:51:55 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/bp-friends/bp-friends-functions.php (modified) (1 diff)
-
tests/phpunit/testcases/friends/functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-functions.php
r9102 r9173 60 60 // Send notifications 61 61 if ( empty( $force_accept ) ) { 62 $action = ' friends_friendship_requested';62 $action = 'requested'; 63 63 64 64 // Update friend totals 65 65 } else { 66 $action = ' friends_friendship_accepted';66 $action = 'accepted'; 67 67 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id, 'add' ); 68 68 } 69 69 70 // Call the above titled action and pass friendship data into it 71 do_action( $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship ); 70 /** 71 * Fires at the end of initiating a new friendship connection. 72 * 73 * This is a variable hook, depending on context. 74 * The two potential hooks are: friends_friendship_requested, friends_friendship_accepted. 75 * 76 * @since BuddyPress (1.0.0) 77 * 78 * @param int $id ID of the pending friendship connection. 79 * @param int $initiator_user_id ID of the friendship initiator. 80 * @param int $friend_user_id ID of the friend user. 81 * @param object $friendship BuddyPress Friendship Object. 82 */ 83 do_action( 'friends_friendship_' . $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship ); 72 84 73 85 return true; -
trunk/tests/phpunit/testcases/friends/functions.php
r9139 r9173 6 6 */ 7 7 class BP_Tests_Friends_Functions extends BP_UnitTestCase { 8 9 protected $filter_fired; 10 11 public function setUp() { 12 parent::setUp(); 13 $this->filter_fired = ''; 14 } 15 16 public function tearDown() { 17 parent::tearDown(); 18 } 8 19 9 20 /** … … 228 239 $this->assertSame( $expected, $found ); 229 240 } 241 242 /** 243 * @group friends_add_friend 244 */ 245 public function test_friends_add_friend_friends_friendship_requested() { 246 $u1 = $this->factory->user->create(); 247 $u2 = $this->factory->user->create(); 248 249 add_filter( 'friends_friendship_requested', array( $this, 'friends_friendship_filter_callback' ) ); 250 $n = friends_add_friend( $u1, $u2, false ); 251 remove_filter( 'friends_friendship_requested', array( $this, 'friends_friendship_filter_callback' ) ); 252 253 $this->assertSame( 'friends_friendship_requested', $this->filter_fired ); 254 } 255 256 /** 257 * @group friends_add_friend 258 */ 259 public function test_friends_add_friend_friends_friendship_accepted() { 260 $u1 = $this->factory->user->create(); 261 $u2 = $this->factory->user->create(); 262 263 add_filter( 'friends_friendship_accepted', array( $this, 'friends_friendship_filter_callback' ) ); 264 $n = friends_add_friend( $u1, $u2, true ); 265 remove_filter( 'friends_friendship_accepted', array( $this, 'friends_friendship_filter_callback' ) ); 266 267 $this->assertSame( 'friends_friendship_accepted', $this->filter_fired ); 268 } 269 270 public function friends_friendship_filter_callback( $value ) { 271 $this->filter_fired = current_filter(); 272 return $value; 273 } 230 274 }
Note: See TracChangeset
for help on using the changeset viewer.