public function testInstantiateStiRecord() { $test = new User(); $model = $test->instantiate(array('id' => '123', 'type' => 'Client')); $this->assertInstanceOf('Client', $model); $this->assertEquals('123', $model->id); }
<?php $success = false; $errors = array(); require 'includes/initialize.php'; if (isset($_POST['email'])) { if (User::email_exists($_POST['email'])) { array_push($errors, 'Email already registered.'); } else { if (strlen($_POST['pwd']) <= 6) { array_push($errors, 'Password length should be greater than 6 characters.'); } else { $user = User::instantiate($_POST); if ($user->create()) { $success = true; } } } } echo '{'; echo "\"success\":"; if ($success) { echo "true"; } else { echo "false"; } echo ","; echo "\"errors\":{"; $i = 0; foreach ($errors as $error) { if ($i != 0) {
<?php require_once '../includes/functions.php'; include 'templates/header.php'; include 'templates/navbar.php'; // FORM SUBMISSION $alert = array(); if (isset($_POST['submit'])) { $new_user = new User(); $_POST['password'] = md5($_POST['password']); $new_user->instantiate($_POST); if (!$new_user->insert()) { $alert['error'] = '<b>Sorry!</b> New user could not be added because the <b>username/email</b> has already been used!'; } else { if (strtolower($new_user->permission) == 'employee') { $employee = new Employee(); $employee->user_id = $new_user->id; $employee->validity = $_POST['validity']; $employee->insert(); } $alert['success'] = '<b>Okay!</b> The new user has been successfully added!'; } } ?> <?php // SETTING PARAMETERS FOR SIDEBAR $header = 'accounts'; $page = 'add'; include 'templates/sidebar.php'; ?>