From d62eb333a7da9b3295dfa5b74a25454e020dbcd1 Mon Sep 17 00:00:00 2001 From: Andrew Summers <18727110+summersab@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:07:49 -0500 Subject: [PATCH] Refactor `OC\Server::getAvatarManager` in user_ldap app Refactor `OC\Server::getAvatarManager` in user_ldap app (missed one) Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com> --- apps/user_ldap/lib/Jobs/Sync.php | 2 +- .../tests/Integration/AbstractIntegrationTest.php | 3 ++- .../Lib/User/IntegrationTestUserAvatar.php | 11 ++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index 16371df156285..0f9e8e3be93b6 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -319,7 +319,7 @@ public function setArgument($argument) { if (isset($argument['avatarManager'])) { $this->avatarManager = $argument['avatarManager']; } else { - $this->avatarManager = \OC::$server->getAvatarManager(); + $this->avatarManager = \OC::$server->get(IAvatarManager::class); } if (isset($argument['dbc'])) { diff --git a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php index 5ec04484bef8d..7cc1ab62a7de0 100644 --- a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php +++ b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php @@ -35,6 +35,7 @@ use OCA\User_LDAP\LDAP; use OCA\User_LDAP\User\Manager; use OCA\User_LDAP\UserPluginManager; +use OCP\IAvatarManager; use OCP\Share\IManager; use Psr\Log\LoggerInterface; @@ -124,7 +125,7 @@ protected function initUserManager() { \OC::$server->getConfig(), new FilesystemHelper(), \OC::$server->get(LoggerInterface::class), - \OC::$server->getAvatarManager(), + \OC::$server->get(IAvatarManager::class), new \OCP\Image(), \OC::$server->getUserManager(), \OC::$server->getNotificationManager(), diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php index c5b7f73bbcc0d..d6fb512010b46 100644 --- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php +++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php @@ -35,6 +35,7 @@ use OCA\User_LDAP\User\User; use OCA\User_LDAP\User_LDAP; use OCA\User_LDAP\UserPluginManager; +use OCP\IAvatarManager; use OCP\Image; use Psr\Log\LoggerInterface; @@ -78,8 +79,8 @@ private function execFetchTest($dn, $username, $image) { \OC_Util::setupFS($username); \OC::$server->getUserFolder($username); \OC::$server->getConfig()->deleteUserValue($username, 'user_ldap', User::USER_PREFKEY_LASTREFRESH); - if (\OC::$server->getAvatarManager()->getAvatar($username)->exists()) { - \OC::$server->getAvatarManager()->getAvatar($username)->remove(); + if (\OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists()) { + \OC::$server->get(IAvatarManager::class)->getAvatar($username)->remove(); } // finally attempt to get the avatar set @@ -99,7 +100,7 @@ protected function case1() { $this->execFetchTest($dn, $username, $image); - return \OC::$server->getAvatarManager()->getAvatar($username)->exists(); + return \OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists(); } /** @@ -116,7 +117,7 @@ protected function case2() { $this->execFetchTest($dn, $username, $image); - return !\OC::$server->getAvatarManager()->getAvatar($username)->exists(); + return !\OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists(); } /** @@ -136,7 +137,7 @@ protected function initUserManager() { \OC::$server->getConfig(), new FilesystemHelper(), \OC::$server->get(LoggerInterface::class), - \OC::$server->getAvatarManager(), + \OC::$server->get(IAvatarManager::class), new Image(), \OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(),