mirror of
https://github.com/buddypress/buddypress.git
synced 2026-07-22 20:56:55 +08:00
We are introducing a new `BP_LoggedIn_User` class to fetch data about a BuddyPress logged-in user. This new addition fixes an issue where a user could be de-authenticated when making REST API requests. Props dcavins, DJPaul, johnjamesjacoby, and imath. Closes https://github.com/buddypress/buddypress/pull/395 See #9229 and #9145 Fixes #7658 git-svn-id: https://buddypress.svn.wordpress.org/trunk@14070 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* @group friends
|
|
* @group routing
|
|
*/
|
|
class BP_Tests_Routing_Friends 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', '' );
|
|
wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
|
}
|
|
|
|
public function tear_down() {
|
|
wp_set_current_user( $this->old_current_user );
|
|
$this->set_permalink_structure( $this->permalink_structure );
|
|
|
|
parent::tear_down();
|
|
}
|
|
|
|
function test_member_friends() {
|
|
$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_friends', bp_get_friends_slug() ),
|
|
)
|
|
)
|
|
);
|
|
$this->assertTrue( bp_is_user_friends() );
|
|
}
|
|
|
|
function test_member_friends_requests() {
|
|
$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_friends', bp_get_friends_slug() ),
|
|
'single_item_action' => bp_rewrites_get_slug( 'members', 'member_friends_requests', 'requests' ),
|
|
)
|
|
)
|
|
);
|
|
$this->assertTrue( bp_is_user_friend_requests() );
|
|
}
|
|
}
|