/** * @dataProvider providerGetUser */ public function testGetUser($uKey, $knownAs) { $u = InstructionControl::getUser($uKey, $knownAs); $this->assertEquals($knownAs, $u['known_as']); $uKey = $u['login_key']; $g = genSaneGuid(); $u = InstructionControl::getUser($uKey, $g); $this->assertEquals($g, $u['known_as']); $this->assertEquals($uKey, $u['login_key']); InstructionControl::setUserDetails($uKey, array('color' => 'FF0000')); $u = InstructionControl::getUser($uKey, $g); $this->assertEquals('FF0000', $u['color']); return $u['communication_key']; }
/** * Allows a user to update his/her user details * * @param array $params Is expected to have the following parameters: * `array('channelset'=>'name of channelset','details'=>array('k'=>'v pairs'))` * @see InstructionControl_Utils_Controller::restGetChannelsetUserCommunicationkey() * for details about the output document */ public function restPutChannelsetUserMe($params) { $channelsetId = $this->getChannelSetId($params['channelset']); $userRec = $this->getUser($channelsetId); InstructionControl::setUserDetails($userRec['login_key'], $params['details']); $userProperties = InstructionControl::getUser($userRec['login_key']); $communicationKey = $userProperties['communication_key']; $userProperties = array_diff_key($userProperties, $this->getProtectedUserPropertyKeys()); $return = InstructionControl::generateReturnDocument('USER_DETAILS', array(), array(), array(), array(), array('communication_key' => $communicationKey, 'details' => $userProperties)); header('HTTP/1.1 202 Accepted'); echo json_encode($return); if (INSTRUCTIONCONTROL__NOTIFY_OTHER_CLIENTS == 'APE') { InstructionControl::notifyOtherClientsApe($params['channelset'], null, $return); } return true; }