Example #1
0
 function test_client_update()
 {
     //Arrange
     $style = "Thai";
     $test_cuisine = new Client($style);
     $test_cuisine->save();
     $name = "Pok Pok";
     $cuisine_id = $test_cuisine->getId();
     $stars = 4;
     $website = "www.pokpokpdx.com";
     $phone = "503 232 1387";
     $tr = new Client($name, $cuisine_id, $stars, $website, $phone);
     $tr->save();
     $new_name = "Pok Pok Noi";
     $new_cuisine_id = $test_cuisine->getId();
     $new_id = $new_stars = 7;
     $new_website = "balls";
     $new_phone = "503 555 5555";
     //Act
     $tr->updateClient($new_name, $tr->getCuisineId(), $tr->getID(), $new_stars, $new_website, $new_phone);
     //Assert
     $this->assertEquals(7, $tr->getStars(), "OH NO");
 }
require_once 'includes/config.php';
if (!empty($_POST['submit_changes'])) {
    $update_flag = true;
    $_POST = sanitize($_POST);
    $_POST['fldClientPassword'] = $_POST['password'];
    unset($_POST['password']);
    unset($_POST['confirm_password']);
    $client = $_POST;
    settype($client, 'object');
    if (!Client::isUniqueUsername($client->fldClientUsername, $client->fldClientID)) {
        $update_flag = false;
        $_SESSION['errors'][] = "Username is already in use.";
    }
    if (!Client::isUniqueEmail($client->fldClientEmail, $client->fldClientID)) {
        $update_flag = false;
        $_SESSION['errors'][] = "Email Address is already in use.";
    }
    // update only if passed all validations
    if ($update_flag) {
        Client::updateClient($client);
        // change password only when user entered something on the password fields
        if (strlen($client->fldClientPassword) > 0) {
            Client::changePassword($client);
        }
        $_SESSION['message'] = "Sucessfully changed.";
    } else {
        // $_SESSION['message'] = "Unable to save your changes.";
    }
    $_SESSION['update_flag'] = $update_flag;
}
header("Location: account-information.php");
Example #3
0
 function test_updateClient()
 {
     $stylist_name = "Sally Vue";
     $id = null;
     $test_stylist = new Stylist($stylist_name, $id);
     $test_stylist->save();
     $stylist_name2 = "Gregory Symfony";
     $test_stylist2 = new Stylist($stylist_name2, $id);
     $test_stylist2->save();
     $test_client = new Client("Jenny Google", $id, "*****@*****.**", $test_stylist->getId());
     $new_client_name = "Frank React";
     $new_email = "*****@*****.**";
     $new_stylist_id = $test_stylist2->getId();
     $new_client = new Client($new_client_name, $id, $new_email, $new_stylist_id);
     $test_client->updateClient($new_client_name, $id, $new_email, $new_stylist_id);
     $this->assertEquals($new_client, $test_client);
 }