Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/07/2023 04:28:08 AM (14 months ago)
Author:
imath
Message:

BP Rewrites: Introduce the bp_members_get_user_url() function

As many member URLs are built concatenating bp_core_get_user_domain()
with URL chunks, the safer way to make sure developers update the way they
build their member URLs in favor of using BP Rewrites is:

  1. to deprecate this function
  2. create a new function bp_members_get_user_url() which is a wrapper of

bp_rewrites_get_url()

  1. replace all bp_core_get_user_domain() occurrences by

bp_members_get_user_url()

This commit also deprecates bp_core_get_username() in favor of the new
bp_members_get_user_slug() function and updates PHPUnit tests.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/70
See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/template/bpUserHasAccess.php

    r11737 r13433  
    55 */
    66class BP_Tests_Core_Template_BpUserHasAccess extends BP_UnitTestCase {
     7    protected $permalink_structure = '';
     8
     9    public function set_up() {
     10        parent::set_up();
     11        $this->permalink_structure = get_option( 'permalink_structure', '' );
     12    }
     13
     14    public function tear_down() {
     15        $this->set_permalink_structure( $this->permalink_structure );
     16
     17        parent::tear_down();
     18    }
     19
    720    public function test_should_return_true_for_bp_moderate_user() {
    821        $users = self::factory()->user->create_many( 2 );
     
    1023        $this->grant_bp_moderate( $users[0] );
    1124        $this->set_current_user( $users[0] );
     25        $this->set_permalink_structure( '/%postname%/' );
    1226
    13         $this->go_to( bp_core_get_user_domain( $users[1] ) );
     27        $this->go_to( bp_members_get_user_url( $users[1] ) );
    1428
    1529        $this->assertTrue( bp_user_has_access( $users[0] ) );
     
    2034
    2135        $this->set_current_user( $users[0] );
     36        $this->set_permalink_structure( '/%postname%/' );
    2237
    23         $this->go_to( bp_core_get_user_domain( $users[1] ) );
     38        $this->go_to( bp_members_get_user_url( $users[1] ) );
    2439
    2540        $this->assertFalse( bp_user_has_access( $users[0] ) );
     
    3045
    3146        $this->set_current_user( $users[0] );
     47        $this->set_permalink_structure( '/%postname%/' );
    3248
    33         $this->go_to( bp_core_get_user_domain( $users[0] ) );
     49        $this->go_to( bp_members_get_user_url( $users[0] ) );
    3450
    3551        $this->assertTrue( bp_user_has_access( $users[0] ) );
Note: See TracChangeset for help on using the changeset viewer.