function first_form_test_success() { global $errors; $_POST['test'] = ""; $_POST['firstname'] = "firstname"; $_POST['lastname'] = "lastname"; $_POST['email'] = "email"; $_POST['password'] = "******"; $_POST['passwordagain'] = "password"; $_POST['role-check'] = "role-check"; process_first_form(); // Assert that mock input is valid assert(empty($erros), "Expected \$errors to be empty"); }
<?php // Dependencies require_once '../includes/dbconnection.php'; require_once '../includes/session.php'; require_once '../includes/navigation.php'; require_once '../includes/validation_functions.php'; require_once '../includes/form_processing.php'; require_once "../includes/output.php"; // Process form from signup.php: if (isset($_POST['submit'])) { //Processes form content and redirects with error feedback if needed process_first_form(); // Process form from address.php } elseif (isset($_POST['second_submit']) && isset($_SESSION['user_details'])) { process_second_form(); // Double check for success of previous form submission before prcoeeding // to send data to the database if (isset($_SESSION['user_details']) && isset($_SESSION['address_details'])) { if (create_new_user()) { //must attempt login in order to get the userId generated from the //database logic $user = attempt_login($_SESSION['email'], $_SESSION['password']); if ($user) { //login successful //restart the session clear_session(); //$_SESSION['logged_in'] = 1; $_SESSION['role'] = $user['role']; $_SESSION['userId'] = $user['userId']; $_SESSION['email'] = $user['email'];