Multisite: Test edit_user
capabilities for multisite administrators
An administrator in multisite can not edit users other than itself. Props daniellandau for the initial patch. See #16860. git-svn-id: https://develop.svn.wordpress.org/trunk@33987 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a025ce4f12
commit
c89822ebe0
@ -936,4 +936,31 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
|||||||
$this->assertFalse( current_user_can( 'edit_post', $post ) );
|
$this->assertFalse( current_user_can( 'edit_post', $post ) );
|
||||||
$this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
|
$this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_multisite_administrator_can_not_edit_users() {
|
||||||
|
if ( ! is_multisite() ) {
|
||||||
|
$this->markTestSkipped( 'Test only runs in multisite' );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
||||||
|
$other_user = new WP_User( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
||||||
|
|
||||||
|
wp_set_current_user( $user->ID );
|
||||||
|
|
||||||
|
$this->assertFalse( current_user_can( 'edit_user', $other_user->ID ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_multisite_user_can_edit_self() {
|
||||||
|
if ( ! is_multisite() ) {
|
||||||
|
$this->markTestSkipped( 'Test only runs in multisite' );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
||||||
|
|
||||||
|
wp_set_current_user( $user->ID );
|
||||||
|
|
||||||
|
$this->assertTrue( current_user_can( 'edit_user', $user->ID ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user