From efa4ea14f62193a0f3ff620d778b9db25407bd84 Mon Sep 17 00:00:00 2001 From: Benjamin Gaussorgues Date: Thu, 3 Oct 2024 16:33:28 +0200 Subject: [PATCH] fix(users): use correct active user count Signed-off-by: Benjamin Gaussorgues --- apps/settings/lib/Controller/UsersController.php | 2 +- tests/lib/User/ManagerTest.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 2e3b0d80ebcfc..46c149a1fed95 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -166,7 +166,7 @@ public function usersList(): TemplateResponse { $recentUsersGroup = [ 'id' => '__nc_internal_recent', 'name' => $this->l10n->t('Recently active'), - 'usercount' => $userCount, + 'usercount' => $this->userManager->countSeenUsers(), ]; $disabledUsersGroup = [ diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php index cb4d19279193a..f194f6e5f55c2 100644 --- a/tests/lib/User/ManagerTest.php +++ b/tests/lib/User/ManagerTest.php @@ -16,6 +16,7 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\IUser; +use OCP\IUserManager; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -579,7 +580,7 @@ public function testCountUsersTwoBackends(): void { } public function testCountUsersOnlyDisabled(): void { - $manager = \OC::$server->getUserManager(); + $manager = \OCP\Server::get(IUserManager::class); // count other users in the db before adding our own $countBefore = $manager->countDisabledUsers(); @@ -604,7 +605,7 @@ public function testCountUsersOnlyDisabled(): void { } public function testCountUsersOnlySeen(): void { - $manager = \OC::$server->getUserManager(); + $manager = \OCP\Server::get(IUserManager::class); // count other users in the db before adding our own $countBefore = $manager->countSeenUsers(); @@ -630,7 +631,7 @@ public function testCountUsersOnlySeen(): void { } public function testCallForSeenUsers(): void { - $manager = \OC::$server->getUserManager(); + $manager = \OCP\Server::get(IUserManager::class); // count other users in the db before adding our own $count = 0; $function = function (IUser $user) use (&$count) { @@ -664,7 +665,7 @@ public function testCallForSeenUsers(): void { } public function testRecentlyActive(): void { - $manager = \OC::$server->getUserManager(); + $manager = \OCP\Server::get(IUserManager::class); $config = \OC::$server->get(IConfig::class); // Create some users