Role/Capability: Reuse a fixture in a couple more unit tests.
See #30017 git-svn-id: https://develop.svn.wordpress.org/trunk@39008 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
249bde034d
commit
5de9799317
@ -1382,13 +1382,17 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
$user = self::$users['administrator'];
|
||||||
$user->add_cap( 'manage_network_users' );
|
$user->add_cap( 'manage_network_users' );
|
||||||
$other_user = self::$users['subscriber'];
|
$other_user = self::$users['subscriber'];
|
||||||
|
|
||||||
wp_set_current_user( $user->ID );
|
wp_set_current_user( $user->ID );
|
||||||
|
|
||||||
$this->assertTrue( current_user_can( 'edit_user', $other_user->ID ) );
|
$can_edit_user = current_user_can( 'edit_user', $other_user->ID );
|
||||||
|
|
||||||
|
$user->remove_cap( 'manage_network_users' );
|
||||||
|
|
||||||
|
$this->assertTrue( $can_edit_user );
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_multisite_administrator_with_manage_network_users_can_not_edit_super_admin() {
|
function test_multisite_administrator_with_manage_network_users_can_not_edit_super_admin() {
|
||||||
@ -1397,14 +1401,19 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
$user = self::$users['administrator'];
|
||||||
$user->add_cap( 'manage_network_users' );
|
$user->add_cap( 'manage_network_users' );
|
||||||
$super_admin = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
$super_admin = self::$users['subscriber'];
|
||||||
grant_super_admin( $super_admin->ID );
|
grant_super_admin( $super_admin->ID );
|
||||||
|
|
||||||
wp_set_current_user( $user->ID );
|
wp_set_current_user( $user->ID );
|
||||||
|
|
||||||
$this->assertFalse( current_user_can( 'edit_user', $super_admin->ID ) );
|
$can_edit_user = current_user_can( 'edit_user', $super_admin->ID );
|
||||||
|
|
||||||
|
$user->remove_cap( 'manage_network_users' );
|
||||||
|
revoke_super_admin( $super_admin->ID );
|
||||||
|
|
||||||
|
$this->assertFalse( $can_edit_user );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user