Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit dbf75a0

Browse files
author
Michael Grauer
committed
BUG: refs #953. changed group.list.users to return names rather than emails.
1 parent 59f7a16 commit dbf75a0

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

modules/api/controllers/components/ApiComponent.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,8 @@ function groupRemove($args)
30483048
* list the users for a group, requires admin privileges on the community
30493049
* assiated with the group
30503050
* @param group_id id of group
3051-
* @return array users => a list of user ids mapped to user emails
3051+
* @return array users => a list of user ids mapped to a two element list of
3052+
* user firstname and lastname
30523053
*/
30533054
function groupListUsers($args)
30543055
{
@@ -3078,7 +3079,7 @@ function groupListUsers($args)
30783079
$userIdsToEmail = array();
30793080
foreach($users as $user)
30803081
{
3081-
$userIdsToEmail[$user->getUserId()] = $user->getEmail();
3082+
$userIdsToEmail[$user->getUserId()] = array('firstname' => $user->getFirstname(), 'lastname' => $user->getLastname());
30823083
}
30833084
return array('users' => $userIdsToEmail);
30843085
}

modules/api/tests/controllers/ApiCallGroupMethodsTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ public function testGroupListUsers()
183183
$commMember = $userModel->load($commMemberId);
184184
$commModerator = $userModel->load($commModeratorId);
185185
$commAdmin = $userModel->load($commAdminId);
186+
$commUsers =
187+
array($commMemberId => $commMember, $commModeratorId => $commModerator, $commAdminId => $commAdmin);
188+
186189

187190
// add in an anonymous user to non admins
188191
$invalidUsers = array($commMember, $commModerator, false);
@@ -205,9 +208,11 @@ public function testGroupListUsers()
205208
$users = $resp->data->users;
206209
$users = (array)$users;
207210
$this->assertEquals(1, sizeof($users), 'users should only have one entry');
208-
foreach($users as $id => $email)
211+
foreach($users as $id => $names)
209212
{
210213
$this->assertEquals($id, $commAdminId, 'users should have commAdminId as an entry');
214+
$this->assertEquals($commUsers[$commAdminId]->getFirstname(), $names->firstname);
215+
$this->assertEquals($commUsers[$commAdminId]->getLastname(), $names->lastname);
211216
}
212217

213218
// add some users, test again
@@ -227,9 +232,11 @@ public function testGroupListUsers()
227232
$users = (array)$users;
228233
$this->assertEquals(3, sizeof($users), 'users should have 3 entries');
229234
$members = array($commAdminId, $commMemberId, $commModeratorId);
230-
foreach($users as $id => $email)
235+
foreach($users as $id => $names)
231236
{
232237
$this->assertTrue(in_array($id, $members), 'users should have '.$id.' as an entry');
238+
$this->assertEquals($commUsers[$id]->getFirstname(), $names->firstname);
239+
$this->assertEquals($commUsers[$id]->getLastname(), $names->lastname);
233240
}
234241

235242
// remove some users, test again
@@ -246,11 +253,12 @@ public function testGroupListUsers()
246253
$users = $resp->data->users;
247254
$users = (array)$users;
248255
$this->assertEquals(1, sizeof($users), 'users should only have one entry');
249-
foreach($users as $id => $email)
256+
foreach($users as $id => $names)
250257
{
251258
$this->assertEquals($id, $commAdminId, 'users should have commAdminId as an entry');
259+
$this->assertEquals($commUsers[$id]->getFirstname(), $names->firstname);
260+
$this->assertEquals($commUsers[$id]->getLastname(), $names->lastname);
252261
}
253-
254262
}
255263

256264
}

0 commit comments

Comments
 (0)