/** * @param IRestServer $server * @param UserItemView $user * @param array|string[] $attributeLabels */ public function __construct(IRestServer $server, UserItemView $user, $attributeLabels) { $userId = $user->Id; $this->id = $userId; $this->dateCreated = $user->DateCreated->ToIso(); $this->emailAddress = $user->Email; $this->firstName = $user->First; $this->lastName = $user->Last; $this->language = $user->Language; $this->lastLogin = $user->LastLogin->ToIso(); $this->organization = $user->Organization; $this->phoneNumber = $user->Phone; $this->position = $user->Position; $this->statusId = $user->StatusId; $this->timezone = $user->Timezone; $this->username = $user->Username; if (!empty($attributeLabels)) { foreach ($attributeLabels as $id => $label) { $this->customAttributes[] = new CustomAttributeResponse($server, $id, $label, $user->GetAttributeValue($id)); } } $this->AddService($server, WebServices::GetUser, array(WebServiceParams::UserId => $userId)); }
public function testCanGetPageableListOfUsers() { $page = 3; $pageSize = 5; $count = 51; $totalPages = 11; $offset = 10; $countRow = array('total' => $count); $row1 = $this->GetUserRow(1, 'first', 'last', 'email', 'un1', '2011-01-01', 'utc', AccountStatus::ACTIVE, null, 'pref1=val1,pref2=val2'); $row2 = $this->GetUserRow(2, 'first', 'last', 'email', null, '2010-01-01'); $userRows = array($row1, $row2); $this->db->SetRow(0, array($countRow)); $this->db->SetRow(1, $userRows); $userRepo = new UserRepository(); $pageable = $userRepo->GetList($page, $pageSize); $this->assertEquals($count, $pageable->PageInfo()->Total); $this->assertEquals($totalPages, $pageable->PageInfo()->TotalPages); $this->assertEquals($pageSize, $pageable->PageInfo()->PageSize); $this->assertEquals($page, $pageable->PageInfo()->CurrentPage); $results = $pageable->Results(); $this->assertEquals(UserItemView::Create($row1), $results[0]); $this->assertEquals(UserItemView::Create($row2), $results[1]); $this->assertEquals($offset, $this->db->_Offset); $this->assertEquals($pageSize, $this->db->_Limit); }