mirror of
https://github.com/buddypress/buddypress.git
synced 2026-07-22 20:56:55 +08:00
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()` 3. 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 git-svn-id: https://buddypress.svn.wordpress.org/trunk@13433 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
78 lines
2.4 KiB
PHP
78 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* @group settings
|
|
* @group routing
|
|
*/
|
|
class BP_Tests_Routing_Settings extends BP_UnitTestCase {
|
|
protected $old_current_user = 0;
|
|
protected $permalink_structure = '';
|
|
|
|
public function set_up() {
|
|
parent::set_up();
|
|
|
|
$this->old_current_user = get_current_user_id();
|
|
$this->permalink_structure = get_option( 'permalink_structure', '' );
|
|
$this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
|
}
|
|
|
|
public function tear_down() {
|
|
parent::tear_down();
|
|
$this->set_current_user( $this->old_current_user );
|
|
$this->set_permalink_structure( $this->permalink_structure );
|
|
}
|
|
|
|
function test_member_settings() {
|
|
$this->set_permalink_structure( '/%postname%/' );
|
|
$this->go_to(
|
|
bp_members_get_user_url(
|
|
bp_loggedin_user_id(),
|
|
array(
|
|
'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
|
|
)
|
|
)
|
|
);
|
|
$this->assertTrue( bp_is_user_settings_general() );
|
|
}
|
|
|
|
function test_member_settings_notifications() {
|
|
$this->set_permalink_structure( '/%postname%/' );
|
|
$this->go_to(
|
|
bp_members_get_user_url(
|
|
bp_loggedin_user_id(),
|
|
array(
|
|
'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
|
|
'single_item_action' => bp_rewrites_get_slug( 'members', 'member_settings_notifications', 'notifications' ),
|
|
)
|
|
)
|
|
);
|
|
$this->assertTrue( bp_is_user_settings_notifications() );
|
|
}
|
|
|
|
// @todo How best to test this?
|
|
/*function bp_is_user_settings_account_capbilities() {
|
|
$this->set_permalink_structure( '/%postname%/' );
|
|
$this->go_to(
|
|
bp_members_get_user_url(
|
|
bp_loggedin_user_id(),
|
|
array(
|
|
'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
|
|
'single_item_action' => bp_rewrites_get_slug( 'members', 'member_settings_capabilities', 'capabilities' ),
|
|
)
|
|
)
|
|
);
|
|
}*/
|
|
|
|
function bp_is_user_settings_account_delete() {
|
|
$this->set_permalink_structure( '/%postname%/' );
|
|
$this->go_to(
|
|
bp_members_get_user_url(
|
|
bp_loggedin_user_id(),
|
|
array(
|
|
'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
|
|
'single_item_action' => bp_rewrites_get_slug( 'members', 'member_settings_delete_account', 'delete-account' ),
|
|
)
|
|
)
|
|
);
|
|
$this->assertTrue( bp_is_user_settings_account_delete() );
|
|
}
|
|
}
|