diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-06 11:48:40 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-06 11:48:40 +0100 |
commit | cc4f4f222d15c22c31aa910d06124534dd69740d (patch) | |
tree | cd41a0476cd91d8c3c3c93ee51b1c0bbba3d07b5 | |
parent | 8047597a81e06ec3f5fced6f1f48b4194d368305 (diff) | |
parent | 292dc553c3bea72deff20392baec1055aaa88446 (diff) | |
download | nextcloud-server-cc4f4f222d15c22c31aa910d06124534dd69740d.tar.gz nextcloud-server-cc4f4f222d15c22c31aa910d06124534dd69740d.zip |
Merge pull request #20348 from owncloud/issue-20303-integer-group-names
Make sure that group names are strings not integers
-rw-r--r-- | lib/private/group/manager.php | 4 | ||||
-rw-r--r-- | tests/lib/group/manager.php | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index 0f6ba7f24e0..73ff0e537c6 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -263,7 +263,9 @@ class Manager extends PublicEmitter implements IGroupManager { * @return array with group ids */ public function getUserGroupIds($user) { - return array_keys($this->getUserGroups($user)); + return array_map(function($value) { + return (string) $value; + }, array_keys($this->getUserGroups($user))); } /** diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php index e3e2a96e46d..6cf473b9156 100644 --- a/tests/lib/group/manager.php +++ b/tests/lib/group/manager.php @@ -304,6 +304,32 @@ class Manager extends \Test\TestCase { $this->assertEquals('group1', $group1->getGID()); } + public function testGetUserGroupIds() { + /** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Group\Manager $manager */ + $manager = $this->getMockBuilder('OC\Group\Manager') + ->disableOriginalConstructor() + ->setMethods(['getUserGroups']) + ->getMock(); + $manager->expects($this->once()) + ->method('getUserGroups') + ->willReturn([ + '123' => '123', + 'abc' => 'abc', + ]); + + /** @var \OC\User\User $user */ + $user = $this->getMockBuilder('OC\User\User') + ->disableOriginalConstructor() + ->getMock(); + + $groups = $manager->getUserGroupIds($user); + $this->assertEquals(2, count($groups)); + + foreach ($groups as $group) { + $this->assertInternalType('string', $group); + } + } + public function testInGroup() { /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend |