mirror of
https://github.com/nextcloud/server.git
synced 2024-08-29 17:54:44 +02:00
Make sure that group names are strings not integers
This commit is contained in:
parent
bf941032a3
commit
292dc553c3
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user