From dd6c8d1cab397e3fc125392cefc1c9588e21b973 Mon Sep 17 00:00:00 2001
From: Joshua Perry <45966243+jpez-development@users.noreply.github.com>
Date: Sun, 5 Feb 2023 23:04:45 +0000
Subject: [PATCH] finished
---
jobs/controllers/Portal.php | 36 +++++++++++++++++++-----------------
phpunit.xml | 8 ++++++++
templates/job_add.html.php | 11 +++++------
templates/nav.html.php | 10 +++++-----
templates/user_add.html.php | 2 +-
tests/testTest.php | 6 ++++++
6 files changed, 44 insertions(+), 29 deletions(-)
create mode 100644 phpunit.xml
create mode 100644 tests/testTest.php
diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php
index d79bdd5..5487a9b 100644
--- a/jobs/controllers/Portal.php
+++ b/jobs/controllers/Portal.php
@@ -150,24 +150,26 @@ class Portal {
public function addUserSubmit() {
if ($_SESSION['userType'] == 'admin') {
- $record = [
- 'username' => $_POST['username'],
- 'password' => password_hash($_POST['password'], PASSWORD_DEFAULT),
- 'userType' => $_POST['type']
- ];
- if ($_POST['submit'] == 'Update') {
- $record['id'] = $_POST['user_id'];
- $this->vars['response'] = 'User Updated Successfully';
+ if($_POST['password'] != "") {
+ $record = [
+ 'username' => $_POST['username'],
+ 'password' => password_hash($_POST['password'], PASSWORD_DEFAULT),
+ 'userType' => $_POST['type']
+ ];
+ if ($_POST['submit'] == 'Update') {
+ $record['id'] = $_POST['user_id'];
+ $this->vars['response'] = 'User Updated Successfully';
+ }
+ else {
+ $this->vars['response'] = 'User Created Successfully';
+ }
+ $this->usersTable->save($record);
+ return [
+ 'template' => 'response.html.php',
+ 'title' => 'Jo\'s Jobs- Edit user',
+ 'vars' => $this->vars
+ ];
}
- else {
- $this->vars['response'] = 'User Created Successfully';
- }
- $this->usersTable->save($record);
- return [
- 'template' => 'response.html.php',
- 'title' => 'Jo\'s Jobs- Edit user',
- 'vars' => $this->vars
- ];
}
}
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 0000000..57f38a9
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,8 @@
+
+
+
+
+ tests
+
+
+
\ No newline at end of file
diff --git a/templates/job_add.html.php b/templates/job_add.html.php
index 9554433..80b9ec6 100644
--- a/templates/job_add.html.php
+++ b/templates/job_add.html.php
@@ -1,12 +1,7 @@