diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-10-09 22:18:39 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-10-10 11:18:57 +0200 |
commit | c1480aade4ebc6988824d93acdb7fe854bdc8be7 (patch) | |
tree | 0ec5ed0b9bea3df2d47f06d06ebd82d88fd9bda5 /apps/user_ldap/tests | |
parent | 039da6bd22dd38cd8e127e604975856c2509995e (diff) | |
download | nextcloud-server-c1480aade4ebc6988824d93acdb7fe854bdc8be7.tar.gz nextcloud-server-c1480aade4ebc6988824d93acdb7fe854bdc8be7.zip |
refactor(LDAP): pass IConfig via constructor to Group_LDAP
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/tests')
-rw-r--r-- | apps/user_ldap/tests/Group_LDAPTest.php | 23 | ||||
-rw-r--r-- | apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php | 3 |
2 files changed, 12 insertions, 14 deletions
diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php index e66fdd633a2..b4789b09c3d 100644 --- a/apps/user_ldap/tests/Group_LDAPTest.php +++ b/apps/user_ldap/tests/Group_LDAPTest.php @@ -40,7 +40,6 @@ use OCA\User_LDAP\User\Manager; use OCA\User_LDAP\User\OfflineUser; use OCP\GroupInterface; use OCP\IConfig; -use OCP\Server; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -52,24 +51,21 @@ use Test\TestCase; * @package OCA\User_LDAP\Tests */ class Group_LDAPTest extends TestCase { + private MockObject|Access $access; + private MockObject|GroupPluginManager $pluginManager; + private MockObject|IConfig $config; + private GroupLDAP $groupBackend; public function setUp(): void { parent::setUp(); $this->access = $this->getAccessMock(); $this->pluginManager = $this->createMock(GroupPluginManager::class); + $this->config = $this->createMock(IConfig::class); } public function initBackend(): void { - $this->groupBackend = new GroupLDAP($this->access, $this->pluginManager); - } - - - public function tearDown(): void { - parent::tearDown(); - - $realConfig = Server::get(IConfig::class); - $realConfig->deleteUserValue('userX', 'user_ldap', 'cached-group-memberships-'); + $this->groupBackend = new GroupLDAP($this->access, $this->pluginManager, $this->config); } public function testCountEmptySearchString() { @@ -848,9 +844,10 @@ class Group_LDAPTest extends TestCase { $offlineUser = $this->createMock(OfflineUser::class); - // FIXME: should be available via CI - $realConfig = Server::get(IConfig::class); - $realConfig->setUserValue('userX', 'user_ldap', 'cached-group-memberships-', \json_encode(['groupB', 'groupF'])); + $this->config->expects($this->any()) + ->method('getUserValue') + ->with('userX', 'user_ldap', 'cached-group-memberships-', $this->anything()) + ->willReturn(\json_encode(['groupB', 'groupF'])); $this->access->userManager->expects($this->any()) ->method('get') diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php index a742c0b8076..e77b3aec6b0 100644 --- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php +++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php @@ -31,6 +31,7 @@ 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\IConfig; use Psr\Log\LoggerInterface; require_once __DIR__ . '/../Bootstrap.php'; @@ -58,7 +59,7 @@ class IntegrationTestAttributeDetection extends AbstractIntegrationTest { $userManager->clearBackends(); $userManager->registerBackend($userBackend); - $groupBackend = new Group_LDAP($this->access, \OC::$server->query(GroupPluginManager::class)); + $groupBackend = new Group_LDAP($this->access, \OC::$server->query(GroupPluginManager::class), \OC::$server->get(IConfig::class)); $groupManger = \OC::$server->getGroupManager(); $groupManger->clearBackends(); $groupManger->addBackend($groupBackend); |