Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/11/2014 03:19:01 PM (11 years ago)
Author:
boonebgorges
Message:

Add 'active_format' parameter to bp_get_member_last_active()

This new param allows theme authors to specify whether they'd like the current
user's last activity string in the format "Active 5 minutes ago" vs the simpler
"5 minutes ago".

Fixes #5387

Props lenasterg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/members/template.php

    r7664 r7846  
    9898    }
    9999
     100    /**
     101     * @group bp_get_member_last_active
     102     */
     103    public function test_bp_get_member_last_active_default_params() {
     104        // Fake the global
     105        global $members_template;
     106
     107        $time = date( 'Y-m-d h:i:s', time() - 24*60*60 );
     108        $members_template = new stdClass;
     109        $members_template->member = new stdClass;
     110        $members_template->member->last_activity = $time;
     111
     112        $this->assertEquals( bp_core_get_last_activity( $time, __( 'active %s', 'buddypress' ) ), bp_get_member_last_active() );
     113    }
     114
     115    /**
     116     * @group bp_get_member_last_active
     117     */
     118    public function test_bp_get_member_last_active_active_format_true() {
     119        // Fake the global
     120        global $members_template;
     121
     122        $time = date( 'Y-m-d h:i:s', time() - 24*60*60 );
     123        $members_template = new stdClass;
     124        $members_template->member = new stdClass;
     125        $members_template->member->last_activity = $time;
     126
     127        $this->assertEquals( bp_core_get_last_activity( $time, __( 'active %s', 'buddypress' ) ), bp_get_member_last_active( array( 'active_format' => true, ) ) );
     128    }
     129
     130    /**
     131     * @group bp_get_member_last_active
     132     */
     133    public function test_bp_get_member_last_active_active_format_false() {
     134        // Fake the global
     135        global $members_template;
     136
     137        $time = date( 'Y-m-d h:i:s', time() - 24*60*60 );
     138        $members_template = new stdClass;
     139        $members_template->member = new stdClass;
     140        $members_template->member->last_activity = $time;
     141
     142        $this->assertEquals( bp_core_time_since( $time ), bp_get_member_last_active( array( 'active_format' => false, ) ) );
     143    }
    100144}
Note: See TracChangeset for help on using the changeset viewer.