Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/08/2016 05:36:58 PM (9 years ago)
Author:
r-a-y
Message:

Friends: Delete 'friendship_created' activity items when a user is deleted.

Fixes #6780.

File:
1 edited

Legend:

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

    r9819 r10563  
    109109        $friendship_id = friends_get_friendship_id( $u2, $u1 );
    110110
    111         // Set current user to u1 to accepte the friendship
     111        // Set current user to u1 to accept the friendship
    112112        $this->set_current_user( $u1 );
    113113        friends_accept_friendship( $friendship_id );
     
    185185        $this->assertTrue( count( $check['activities'] ) == 1 );
    186186    }
     187
     188    /**
     189     * @group friends_delete_activity
     190     */
     191    public function test_delete_friendship_activity_on_user_delete() {
     192        $old_user = get_current_user_id();
     193
     194        $u1 = $this->factory->user->create();
     195        $u2 = $this->factory->user->create();
     196
     197        friends_add_friend( $u2, $u1 );
     198        $friendship_id = friends_get_friendship_id( $u2, $u1 );
     199
     200        // Set current user to u1 to accept the friendship
     201        $this->set_current_user( $u1 );
     202        friends_accept_friendship( $friendship_id );
     203
     204        // Reset the current user
     205        $this->set_current_user( $old_user );
     206
     207        // Delete $u1.
     208        wp_delete_user( $u1 );
     209
     210        // 'friendship_created' activity item should not exist.
     211        $friendship_activity = bp_activity_get( array(
     212            'component' => buddypress()->friends->id,
     213            'filter'    => array(
     214                'action' => array( 'friendship_created' ),
     215                'primary_id' => $friendship_id,
     216            )
     217        ) );
     218
     219        $this->assertEmpty( $friendship_activity['activities'] );
     220    }
    187221}
    188222
Note: See TracChangeset for help on using the changeset viewer.