Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/04/2014 08:17:51 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Use bp_update_user_meta() in bp_update_user_last_activity() to ensure bp_get_user_meta_key filter is ran.

Fixes bug causing last_activity meta to not be prefixed, and includes testcase.

Fixes #5988.

File:
1 edited

Legend:

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

    r8958 r9123  
    412412        $this->assertSame( NULL, bp_core_get_userid_from_nicename( 'non_existent_user' ) );
    413413    }
     414
     415    /**
     416     * @group bp_update_user_last_activity
     417     */
     418    public function test_bp_last_activity_multi_network() {
     419
     420        // Filter the usermeta key
     421        add_filter( 'bp_get_user_meta_key', array( $this, 'filter_usermeta_key' ) );
     422
     423        // We explicitly do not want last_activity created, so use the
     424        // WP factory methods
     425        $user = $this->factory->user->create();
     426        $time = date( 'Y-m-d H:i:s', time() - 50 );
     427
     428        // Update last user activity
     429        bp_update_user_last_activity( $user, $time );
     430
     431        // Setup parameters to assert to be the same
     432        $expected = $time;
     433        $found    = bp_get_user_meta( $user, 'last_activity', true );
     434
     435        $this->assertSame( $expected, $found );
     436    }
     437
     438    /**
     439     * @group bp_update_user_last_activity
     440     * @global object $wpdb
     441     * @param  string $key
     442     * @return string
     443     */
     444    public function filter_usermeta_key( $key ) {
     445        global $wpdb;
     446        return $wpdb->prefix . $key;
     447    }
    414448}
Note: See TracChangeset for help on using the changeset viewer.