[Pkg-owncloud-commits] [owncloud] 36/69: Make sure that group names are strings not integers
David Prévot
taffit at moszumanska.debian.org
Wed Nov 11 02:04:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit ad64a2408132c93b94802f3b6aa44aca56b6d764
Author: Joas Schilling <nickvergessen at owncloud.com>
Date: Fri Nov 6 10:40:09 2015 +0100
Make sure that group names are strings not integers
---
lib/private/group/manager.php | 4 +++-
tests/lib/group/manager.php | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 65ae49d..acc8fa6 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -261,7 +261,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 e3e2a96..6cf473b 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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list