diff options
Diffstat (limited to 'apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php')
-rw-r--r-- | apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php index 7353c5bef30..6fbfd9ba51b 100644 --- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php +++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php @@ -1,38 +1,26 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\User_LDAP\Tests\Integration\Lib\User; use OCA\User_LDAP\Mapping\UserMapping; use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest; +use OCA\User_LDAP\User\DeletedUsersIndex; use OCA\User_LDAP\User_LDAP; use OCA\User_LDAP\UserPluginManager; +use OCP\IDBConnection; +use OCP\IUserManager; +use OCP\Server; +use Psr\Log\LoggerInterface; require_once __DIR__ . '/../../Bootstrap.php'; class IntegrationTestUserDisplayName extends AbstractIntegrationTest { - /** @var UserMapping */ + /** @var UserMapping */ protected $mapping; /** @@ -42,11 +30,11 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest { public function init() { require(__DIR__ . '/../../setup-scripts/createExplicitUsers.php'); parent::init(); - $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection()); + $this->mapping = new UserMapping(Server::get(IDBConnection::class)); $this->mapping->clear(); $this->access->setUserMapper($this->mapping); - $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class)); - \OC_User::useBackend($userBackend); + $userBackend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class)); + Server::get(IUserManager::class)->registerBackend($userBackend); } /** @@ -69,9 +57,9 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest { $username = 'alice1337'; $dn = 'uid=alice,ou=Users,' . $this->base; $this->prepareUser($dn, $username); - $displayName = \OC::$server->getUserManager()->get($username)->getDisplayName(); + $displayName = Server::get(IUserManager::class)->get($username)->getDisplayName(); - return strpos($displayName, '(Alice@example.com)') !== false; + return str_contains($displayName, '(Alice@example.com)'); } /** @@ -86,9 +74,9 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest { $username = 'boris23421'; $dn = 'uid=boris,ou=Users,' . $this->base; $this->prepareUser($dn, $username); - $displayName = \OC::$server->getUserManager()->get($username)->getDisplayName(); + $displayName = Server::get(IUserManager::class)->get($username)->getDisplayName(); - return strpos($displayName, '(Boris@example.com)') === false; + return !str_contains($displayName, '(Boris@example.com)'); } /** |