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/routing/settings.php

    r13314 r13433  
    66class BP_Tests_Routing_Settings extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1112
    1213        $this->old_current_user = get_current_user_id();
     14        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1315        $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1416    }
     
    1719        parent::tear_down();
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922    }
    2023
    2124    function test_member_settings() {
    22         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() );
     25        $this->set_permalink_structure( '/%postname%/' );
     26        $this->go_to(
     27            bp_members_get_user_url(
     28                bp_loggedin_user_id(),
     29                array(
     30                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     31                )
     32            )
     33        );
    2334        $this->assertTrue( bp_is_user_settings_general() );
    2435    }
    2536
    2637    function test_member_settings_notifications() {
    27         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/notifications' );
     38        $this->set_permalink_structure( '/%postname%/' );
     39        $this->go_to(
     40            bp_members_get_user_url(
     41                bp_loggedin_user_id(),
     42                array(
     43                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     44                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_notifications', 'notifications' ),
     45                )
     46            )
     47        );
    2848        $this->assertTrue( bp_is_user_settings_notifications() );
    2949    }
     
    3151    // @todo How best to test this?
    3252    /*function bp_is_user_settings_account_capbilities() {
    33         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/capabilities' );
     53        $this->set_permalink_structure( '/%postname%/' );
     54        $this->go_to(
     55            bp_members_get_user_url(
     56                bp_loggedin_user_id(),
     57                array(
     58                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     59                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_capabilities', 'capabilities' ),
     60                )
     61            )
     62        );
    3463    }*/
    3564
    3665    function bp_is_user_settings_account_delete() {
    37         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/delete-account' );
     66        $this->set_permalink_structure( '/%postname%/' );
     67        $this->go_to(
     68            bp_members_get_user_url(
     69                bp_loggedin_user_id(),
     70                array(
     71                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     72                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_delete_account', 'delete-account' ),
     73                )
     74            )
     75        );
    3876        $this->assertTrue( bp_is_user_settings_account_delete() );
    3977    }
Note: See TracChangeset for help on using the changeset viewer.