Merge pull request #5434 from owncloud/fix5209
dispayNamesInGroup(s) should always return uid as key in the result array, fixes #5209
This commit is contained in:
commit
dfe38d13e2
|
@ -268,7 +268,7 @@ class OC_Group {
|
||||||
$users = $group->searchDisplayName($search, $limit, $offset);
|
$users = $group->searchDisplayName($search, $limit, $offset);
|
||||||
$displayNames = array();
|
$displayNames = array();
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$displayNames[] = $user->getDisplayName();
|
$displayNames[$user->getUID()] = $user->getDisplayName();
|
||||||
}
|
}
|
||||||
return $displayNames;
|
return $displayNames;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -109,6 +109,24 @@ class Test_Group extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals(array(), OC_Group::getGroups());
|
$this->assertEquals(array(), OC_Group::getGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDisplayNamesInGroup() {
|
||||||
|
OC_Group::useBackend(new OC_Group_Dummy());
|
||||||
|
$userBackend = new \OC_User_Dummy();
|
||||||
|
\OC_User::getManager()->registerBackend($userBackend);
|
||||||
|
|
||||||
|
$group1 = uniqid();
|
||||||
|
$user1 = 'uid1';
|
||||||
|
$user2 = 'uid2';
|
||||||
|
OC_Group::createGroup($group1);
|
||||||
|
$userBackend->createUser($user1, '');
|
||||||
|
$userBackend->createUser($user2, '');
|
||||||
|
OC_Group::addToGroup($user1, $group1);
|
||||||
|
OC_Group::addToGroup($user2, $group1);
|
||||||
|
//Dummy backend does not support setting displaynames, uid will always
|
||||||
|
//be returned. This checks primarily, that the return format is okay.
|
||||||
|
$expected = array($user1 => $user1, $user2 => $user2);
|
||||||
|
$this->assertEquals($expected, OC_Group::displayNamesInGroup($group1));
|
||||||
|
}
|
||||||
|
|
||||||
public function testUsersInGroup() {
|
public function testUsersInGroup() {
|
||||||
OC_Group::useBackend(new OC_Group_Dummy());
|
OC_Group::useBackend(new OC_Group_Dummy());
|
||||||
|
|
Loading…
Reference in New Issue