Skip to:
Content

BuddyPress.org

Changeset 9525


Ignore:
Timestamp:
02/22/2015 09:48:26 PM (9 years ago)
Author:
boonebgorges
Message:

Fix syntax typo in BP_Friends_Friendship::save().

An extraneous bracket was making it impossible to save an existing friendship
object.

Props sbrajesh.
Fixes #6247.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/classes/class-bp-friends-friendship.php

    r9486 r9525  
    161161        // Update
    162162        if (!empty( $this->id ) ) {
    163             $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = %s ) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );
     163            $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = %s WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );
    164164
    165165        // Save
  • trunk/tests/phpunit/testcases/friends/class-bp-friends-friendship.php

    r9139 r9525  
    116116        $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
    117117    }
     118
     119    /**
     120     * @group BP6247
     121     */
     122    public function test_save_method_should_update_existing_row() {
     123        $u1 = $this->factory->user->create();
     124        $u2 = $this->factory->user->create();
     125
     126        $friendship = new BP_Friends_Friendship();
     127        $friendship->initiator_user_id = $u1;
     128        $friendship->friend_user_id = $u2;
     129        $friendship->is_confirmed = 0;
     130        $friendship->is_limited = 0;
     131        $friendship->date_created = bp_core_current_time();
     132        $friendship->is_confirmed = 1;
     133        $friendship->save();
     134
     135        $fid = $friendship->id;
     136
     137        $f = new BP_Friends_Friendship( $fid );
     138        $f->is_confirmed = 1;
     139        $f->save();
     140
     141        $f2 = new BP_Friends_Friendship( $fid );
     142        $this->assertEquals( 1, $f2->is_confirmed );
     143    }
    118144}
Note: See TracChangeset for help on using the changeset viewer.