Users: Ensure that users with no role on a site are taken into consideration when listing users on Multisite.

This ensures that users who are a member of a site but have no role are correctly listed on the Users screen and can be filtered from the 'None' role filter.

Props tobi823, flixos90, scottlee

Fixes #36196


git-svn-id: https://develop.svn.wordpress.org/trunk@41138 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2017-07-25 00:23:44 +00:00
parent 06160eb060
commit 44491ba49f
4 changed files with 33 additions and 27 deletions
+2 -1
View File
@@ -52,6 +52,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase {
/**
* @ticket 22993
* @ticket 36196
* @group multisite
* @group ms-required
*
@@ -103,7 +104,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase {
'author' => 1,
'contributor' => 1,
'subscriber' => 1,
'none' => 0,
'none' => 2,
), $count['avail_roles'] );
// Test users counts on blog 1
@@ -36,6 +36,7 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase {
/**
* @ticket 22993
* @ticket 36196
* @group multisite
* @group ms-required
*/
@@ -56,21 +57,27 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase {
'user_id' => $editor,
) );
// Add users to blogs
// Add editor to blog 1
add_user_to_blog( $blog_1, $editor, 'editor' );
// Test users on root site
$users = wp_get_users_with_no_role();
$this->assertSame( array(), $users );
$this->assertSame( array(
"{$nobody}",
), $users );
// Test users counts on blog 1
switch_to_blog( $blog_1 );
$users = wp_get_users_with_no_role();
restore_current_blog();
// Test users on root site
$users = wp_get_users_with_no_role( $blog_1 );
$this->assertSame( array(), $users );
// Add admin to blog 1 with no role
add_user_to_blog( $blog_1, $admin, '' );
// Re-test users counts on blog 1
$users = wp_get_users_with_no_role( $blog_1 );
$this->assertSame( array(
"{$admin}",
), $users );
}
/**