Example #1
0
if (WEB::_action('generate_new_api_key')) {
    if (!$u->generateNewApiKey()) {
        $status_message = WEB::_error('Failed to Genereate New API Key!', null);
    }
}
// Handle Post Request
if (WEB::_req('POST')) {
    $user_name = WEB::_post('user_name');
    $user_email = WEB::_post('user_email');
    $user_password = WEB::_post('user_password');
    $user_notify = WEB::_post('user_notify');
    $form_error = $u->validateParams(array($user_name, $user_email, $user_password));
    $updateStatus = true;
    if (is_null($form_error)) {
        if (!is_null($user_name)) {
            $updateStatus = $u->updateUserName($user_name);
        }
        if ($updateStatus && !is_null($user_email)) {
            $updateStatus = $u->updateUserEmail($user_email);
        }
        if ($updateStatus && !is_null($user_email)) {
            $updateStatus = $u->updateUserPassword($user_password);
        }
        if ($updateStatus) {
            $updateStatus = $u->updateUserNotify($user_notify);
        }
        if ($updateStatus) {
            $u->refresh();
            $status_message = WEB::_success('User Successfully updated!');
        } else {
            $status_message = WEB::_error('There was an error when you were updating the User.', null);
Example #2
0
 function testUpdateUserName()
 {
     //Arrange
     $user_name = "Barack Obama";
     $preferred_style = "IPA";
     $region = "Northwest";
     $id = 1;
     $test_user = new User($user_name, $preferred_style, $region, $id);
     $test_user->save();
     //Act
     $test_user->updateUserName("Miley Cyrus");
     //Assert
     $this->assertEquals("Miley Cyrus", $test_user->getUserName());
 }