Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/25/2014 02:51:55 PM (11 years ago)
Author:
boonebgorges
Message:

Generate friend initiation hook dynamically.

This makes it easier to document per WP standards.

Props tw2113.
See #5942.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/friends/functions.php

    r9139 r9173  
    66 */
    77class 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    }
    819
    920    /**
     
    228239        $this->assertSame( $expected, $found );
    229240    }
     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    }
    230274}
Note: See TracChangeset for help on using the changeset viewer.