| | 242 | |
| | 243 | /** |
| | 244 | * @group friends_add_friend |
| | 245 | */ |
| | 246 | public function test_friends_add_friend_friends_friendship_requested() { |
| | 247 | $u1 = $this->factory->user->create(); |
| | 248 | $u2 = $this->factory->user->create(); |
| | 249 | |
| | 250 | add_filter( 'friends_friendship_requested', array( $this, 'friends_friendship_filter_callback' ) ); |
| | 251 | $n = friends_add_friend( $u1, $u2, false ); |
| | 252 | remove_filter( 'friends_friendship_requested', array( $this, 'friends_friendship_filter_callback' ) ); |
| | 253 | |
| | 254 | $this->assertSame( 'friends_friendship_requested', $this->filter_fired ); |
| | 255 | } |
| | 256 | |
| | 257 | /** |
| | 258 | * @group friends_add_friend |
| | 259 | */ |
| | 260 | public function test_friends_add_friend_friends_friendship_accepted() { |
| | 261 | $u1 = $this->factory->user->create(); |
| | 262 | $u2 = $this->factory->user->create(); |
| | 263 | |
| | 264 | add_filter( 'friends_friendship_accepted', array( $this, 'friends_friendship_filter_callback' ) ); |
| | 265 | $n = friends_add_friend( $u1, $u2, true ); |
| | 266 | remove_filter( 'friends_friendship_accepted', array( $this, 'friends_friendship_filter_callback' ) ); |
| | 267 | |
| | 268 | $this->assertSame( 'friends_friendship_accepted', $this->filter_fired ); |
| | 269 | } |
| | 270 | |
| | 271 | public function friends_friendship_filter_callback( $value ) { |
| | 272 | $this->filter_fired = current_filter(); |
| | 273 | |
| | 274 | return $value; |
| | 275 | } |
| | 276 | |