]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix user_ldap unit tests 31661/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Wed, 30 Mar 2022 10:50:02 +0000 (12:50 +0200)
committerCôme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com>
Fri, 1 Apr 2022 12:18:03 +0000 (12:18 +0000)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/user_ldap/lib/GroupPluginManager.php
apps/user_ldap/tests/GroupLDAPPluginTest.php
apps/user_ldap/tests/Group_LDAPTest.php

index 8403ad4e4be297ab5a02cd6209199c94e4f09156..5999409cdba34edf342703c106dc56074647c743 100644 (file)
@@ -88,7 +88,7 @@ class GroupPluginManager {
        }
 
        public function canDeleteGroup(): bool {
-               return !$this->suppressDeletion && ($this->which[GroupInterface::DELETE_GROUP] !== null);
+               return !$this->suppressDeletion && $this->implementsActions(GroupInterface::DELETE_GROUP);
        }
 
        /**
@@ -102,11 +102,10 @@ class GroupPluginManager {
 
        /**
         * Delete a group
-        * @param string $gid Group Id of the group to delete
-        * @return bool
+        *
         * @throws \Exception
         */
-       public function deleteGroup($gid) {
+       public function deleteGroup(string $gid): bool {
                $plugin = $this->which[GroupInterface::DELETE_GROUP];
 
                if ($plugin) {
index b55f57990a00c3f118c15a2b6927a6ee3eb44df8..660608d6b1fbb76a8a19695d2aa87a5133f20a25 100644 (file)
@@ -84,7 +84,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
                $pluginManager->createGroup('group');
        }
 
-       
+
        public function testCreateGroupNotRegistered() {
                $this->expectException(\Exception::class);
                $this->expectExceptionMessage('No plugin implements createGroup in this LDAP Backend.');
@@ -108,13 +108,13 @@ class GroupLDAPPluginTest extends \Test\TestCase {
                        ->method('deleteGroup')
                        ->with(
                                $this->equalTo('group')
-                       );
+                       )->willReturn(true);
 
                $pluginManager->register($plugin);
-               $pluginManager->deleteGroup('group');
+               $this->assertTrue($pluginManager->deleteGroup('group'));
        }
 
-       
+
        public function testDeleteGroupNotRegistered() {
                $this->expectException(\Exception::class);
                $this->expectExceptionMessage('No plugin implements deleteGroup in this LDAP Backend.');
@@ -145,7 +145,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
                $pluginManager->addToGroup('uid', 'gid');
        }
 
-       
+
        public function testAddToGroupNotRegistered() {
                $this->expectException(\Exception::class);
                $this->expectExceptionMessage('No plugin implements addToGroup in this LDAP Backend.');
@@ -176,7 +176,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
                $pluginManager->removeFromGroup('uid', 'gid');
        }
 
-       
+
        public function testRemoveFromGroupNotRegistered() {
                $this->expectException(\Exception::class);
                $this->expectExceptionMessage('No plugin implements removeFromGroup in this LDAP Backend.');
@@ -207,7 +207,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
                $pluginManager->countUsersInGroup('gid', 'search');
        }
 
-       
+
        public function testCountUsersInGroupNotRegistered() {
                $this->expectException(\Exception::class);
                $this->expectExceptionMessage('No plugin implements countUsersInGroup in this LDAP Backend.');
@@ -237,7 +237,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
                $pluginManager->getGroupDetails('gid');
        }
 
-       
+
        public function testgetGroupDetailsNotRegistered() {
                $this->expectException(\Exception::class);
                $this->expectExceptionMessage('No plugin implements getGroupDetails in this LDAP Backend.');
index f8327c0776c33019a35e371f8c7176277180f15f..6204c22cb9e90f5fdacf09d9c6ec254d4a4286d2 100644 (file)
@@ -1092,7 +1092,7 @@ class Group_LDAPTest extends TestCase {
                $pluginManager->expects($this->once())
                        ->method('deleteGroup')
                        ->with('gid')
-                       ->willReturn('result');
+                       ->willReturn(true);
 
                $mapper = $this->getMockBuilder(GroupMapping::class)
                        ->setMethods(['unmap'])
@@ -1108,7 +1108,7 @@ class Group_LDAPTest extends TestCase {
 
                $ldap = new GroupLDAP($access, $pluginManager);
 
-               $this->assertEquals($ldap->deleteGroup('gid'), 'result');
+               $this->assertTrue($ldap->deleteGroup('gid'));
        }