diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-06-25 09:15:04 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-06-25 09:15:04 +0200 |
commit | b828d2885d62f825b21a791796a40fed8f9ec411 (patch) | |
tree | 0dba833b8106451c12fa819b79884466c7149ea4 | |
parent | f4e0b344c45f3c68c4de70b78bcb6b5f13039229 (diff) | |
parent | 5e555f18b161a6ac9a97c2fe980c89bd237575b6 (diff) | |
download | nextcloud-server-b828d2885d62f825b21a791796a40fed8f9ec411.tar.gz nextcloud-server-b828d2885d62f825b21a791796a40fed8f9ec411.zip |
Merge pull request #17155 from owncloud/fix-15590-stable8
Backport of #15592 to stable8
-rw-r--r-- | lib/private/group/manager.php | 6 | ||||
-rw-r--r-- | tests/lib/group/manager.php | 22 |
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index 8dcf14fc1d2..56b82c419db 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -184,8 +184,10 @@ class Manager extends PublicEmitter implements IGroupManager { $groups = array(); foreach ($this->backends as $backend) { $groupIds = $backend->getUserGroups($uid); - foreach ($groupIds as $groupId) { - $groups[$groupId] = $this->get($groupId); + if (is_array($groupIds)) { + foreach ($groupIds as $groupId) { + $groups[$groupId] = $this->get($groupId); + } } } $this->cachedUserGroups[$uid] = $groups; diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php index e3462caf806..80b7951cea3 100644 --- a/tests/lib/group/manager.php +++ b/tests/lib/group/manager.php @@ -846,4 +846,26 @@ class Manager extends \Test\TestCase { $groups = $manager->getUserGroups($user1); $this->assertEquals(array(), $groups); } + + public function testGetUserIdGroups() { + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend + */ + $backend = $this->getMock('\OC_Group_Database'); + $backend->expects($this->any()) + ->method('getUserGroups') + ->with('user1') + ->will($this->returnValue(null)); + + /** + * @var \OC\User\Manager $userManager + */ + $userManager = $this->getMock('\OC\User\Manager'); + $manager = new \OC\Group\Manager($userManager); + $manager->addBackend($backend); + + $groups = $manager->getUserIdGroups('user1'); + $this->assertEquals([], $groups); + } + } |