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/members.php

    r13431 r13433  
    66class BP_Tests_Routing_Members extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1213        buddypress()->members->types = array();
    1314        $this->old_current_user = get_current_user_id();
     15        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1416        $this->set_current_user( self::factory()->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
    1517    }
     
    1719    public function tear_down() {
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922        parent::tear_down();
    2023    }
    2124
    2225    function test_members_directory() {
     26        $this->set_permalink_structure( '/%postname%/' );
    2327        $this->go_to( bp_get_members_directory_permalink() );
    2428
     
    3034
    3135    function test_member_permalink() {
    32         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) );
     36        $this->set_permalink_structure( '/%postname%/' );
     37        $this->go_to( bp_members_get_user_url( bp_loggedin_user_id() ) );
    3338        $this->assertTrue( bp_is_my_profile() );
    3439    }
     
    3944     */
    4045    public function test_member_directory_with_member_type() {
     46        $this->set_permalink_structure( '/%postname%/' );
    4147        bp_register_member_type( 'foo' );
    4248        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
     
    4955     */
    5056    public function test_member_directory_with_member_type_should_obey_filtered_type_slug() {
     57        $this->set_permalink_structure( '/%postname%/' );
    5158        bp_register_member_type( 'foo' );
    5259
     
    6673     */
    6774    public function test_member_directory_with_member_type_that_has_custom_directory_slug() {
     75        $this->set_permalink_structure( '/%postname%/' );
    6876        bp_register_member_type( 'foo', array( 'has_directory' => 'foos' ) );
    6977        $this->go_to( bp_get_members_directory_permalink() . 'type/foos/' );
     
    7684     */
    7785    public function test_member_directory_with_member_type_should_be_overridden_by_member_with_same_nicename() {
     86        $this->set_permalink_structure( '/%postname%/' );
    7887        $u = self::factory()->user->create( array( 'user_nicename' => 'foo' ) );
    7988        bp_register_member_type( 'foo' );
     
    91100     */
    92101    public function test_member_directory_should_404_for_member_types_that_have_no_directory() {
     102        $this->set_permalink_structure( '/%postname%/' );
    93103        bp_register_member_type( 'foo', array( 'has_directory' => false ) );
    94104        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
     
    100110     */
    101111    function test_members_shortlink_redirector() {
     112        $this->set_permalink_structure( '/%postname%/' );
    102113        $shortlink_member_slug = 'me';
    103114
Note: See TracChangeset for help on using the changeset viewer.