Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/20/2014 04:29:56 PM (12 years ago)
Author:
imath
Message:

Make sure activities about a friendship are removed when this friendship is cancelled

Fixes #6055

File:
1 edited

Legend:

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

    r9139 r9241  
    4949                $this->assertSame( $expected, $a_obj->action );
    5050        }
     51
     52        /**
     53         * @group friends_delete_activity
     54         */
     55        public function test_friends_delete_activity() {
     56                $old_user = get_current_user_id();
     57
     58                $u1 = $this->factory->user->create();
     59                $u2 = $this->factory->user->create();
     60
     61                friends_add_friend( $u2, $u1 );
     62                $friendship_id = friends_get_friendship_id( $u2, $u1 );
     63
     64                // Set current user to u1 to accepte the friendship
     65                $this->set_current_user( $u1 );
     66                friends_accept_friendship( $friendship_id );
     67
     68                // Reset the current user
     69                $this->set_current_user( $old_user );
     70
     71                // Random activities
     72                $au1 = $this->factory->activity->create( array( 'user_id' => $u1 ) );
     73                $au2 = $this->factory->activity->create( array( 'user_id' => $u2 ) );
     74
     75                $fc_act = bp_activity_get( array(
     76                        'component'   => buddypress()->friends->id,
     77                        'item_id'     => $friendship_id,
     78                        'filter'      => array( 'action' => array( 'friendship_created' ) ),
     79                        'show_hidden' => false
     80                ) );
     81
     82                $this->assertTrue( count( $fc_act['activities'] ) == 1, '1 public activity should be created when a friendship is confirmed' );
     83
     84                // Remove the friendship
     85                friends_remove_friend( $u2, $u1 );
     86
     87                $this->assertFalse( friends_check_friendship( $u2, $u1 ), '2 users should not be friend once the friendship is removed' );
     88
     89                $fd_act = bp_activity_get( array(
     90                        'component'   => buddypress()->friends->id,
     91                        'item_id'     => $friendship_id,
     92                        'filter'      => array( 'action' => array( 'friendship_created' ) ),
     93                        'show_hidden' => true
     94                ) );
     95
     96                $this->assertTrue( count( $fd_act['activities'] ) == 0, 'friends_delete_activity() should remove "friendship_created" activities about a deleted friendship' );
     97        }
    5198}
    5299
Note: See TracChangeset for help on using the changeset viewer.