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

Commit

Permalink
BUG: refs #953. changed group.list.users to return names rather than …
Browse files Browse the repository at this point in the history
…emails.
  • Loading branch information
Michael Grauer committed Mar 8, 2013
1 parent 59f7a16 commit dbf75a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions modules/api/controllers/components/ApiComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3048,7 +3048,8 @@ function groupRemove($args)
* list the users for a group, requires admin privileges on the community
* assiated with the group
* @param group_id id of group
* @return array users => a list of user ids mapped to user emails
* @return array users => a list of user ids mapped to a two element list of
* user firstname and lastname
*/
function groupListUsers($args)
{
Expand Down Expand Up @@ -3078,7 +3079,7 @@ function groupListUsers($args)
$userIdsToEmail = array();
foreach($users as $user)
{
$userIdsToEmail[$user->getUserId()] = $user->getEmail();
$userIdsToEmail[$user->getUserId()] = array('firstname' => $user->getFirstname(), 'lastname' => $user->getLastname());
}
return array('users' => $userIdsToEmail);
}
Expand Down
16 changes: 12 additions & 4 deletions modules/api/tests/controllers/ApiCallGroupMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ public function testGroupListUsers()
$commMember = $userModel->load($commMemberId);
$commModerator = $userModel->load($commModeratorId);
$commAdmin = $userModel->load($commAdminId);
$commUsers =
array($commMemberId => $commMember, $commModeratorId => $commModerator, $commAdminId => $commAdmin);


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

// add some users, test again
Expand All @@ -227,9 +232,11 @@ public function testGroupListUsers()
$users = (array)$users;
$this->assertEquals(3, sizeof($users), 'users should have 3 entries');
$members = array($commAdminId, $commMemberId, $commModeratorId);
foreach($users as $id => $email)
foreach($users as $id => $names)
{
$this->assertTrue(in_array($id, $members), 'users should have '.$id.' as an entry');
$this->assertEquals($commUsers[$id]->getFirstname(), $names->firstname);
$this->assertEquals($commUsers[$id]->getLastname(), $names->lastname);
}

// remove some users, test again
Expand All @@ -246,11 +253,12 @@ public function testGroupListUsers()
$users = $resp->data->users;
$users = (array)$users;
$this->assertEquals(1, sizeof($users), 'users should only have one entry');
foreach($users as $id => $email)
foreach($users as $id => $names)
{
$this->assertEquals($id, $commAdminId, 'users should have commAdminId as an entry');
$this->assertEquals($commUsers[$id]->getFirstname(), $names->firstname);
$this->assertEquals($commUsers[$id]->getLastname(), $names->lastname);
}

}

}

0 comments on commit dbf75a0

Please sign in to comment.