Пример #1
0
 public function testShowUserViewWithNullUser()
 {
     ob_start();
     $return = UserView::show(null);
     $output = ob_get_clean();
     $this->assertFalse(empty($output), "It should show a User view when passed a null user");
 }
Пример #2
0
 public function testShowUserViewWithNullUser()
 {
     ob_start();
     $_SESSION = array('user' => null, 'base' => 'mvcdbcrud');
     $return = UserView::show();
     $output = ob_get_clean();
     $this->assertFalse(empty($output), "It should show a User view when passed a null user");
 }
 public static function newUser()
 {
     // Process a new review
     $user = null;
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $user = new User($_POST);
     }
     if (is_null($user) || $user->getErrorCount() != 0) {
         $_SESSION['user'] = $user;
         UserView::show();
     } else {
         HomeView::show();
         header('Location: /' . $_SESSION['base']);
     }
 }
Пример #4
0
 public static function run()
 {
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $user = new User($_POST);
         // What if already logged in?
         if ($user->getErrorCount() == 0) {
             UserView::show($user);
         } else {
             LoginView::show($user);
         }
     } else {
         // Initial link
         LoginView::show(null);
     }
 }
 public static function show()
 {
     $arguments = array_key_exists('arguments', $_SESSION) ? $_SESSION['arguments'] : 0;
     $user = $_SESSION['user'];
     if (!is_null($user)) {
         $_SESSION['user'] = $user;
         $userDataArray = UserDataDB::getUserDataBy('userId', $user->getUserId());
         $userData = $userDataArray[0];
         $_SESSION['userData'] = $userData;
         $skillAssocs = SkillAssocsDB::getSkillAssocsBy('userDataId', $userData->getUserDataId());
         $_SESSION['skillAssocs'] = $skillAssocs;
         // The robot data section might look something like this:
         //$robotDataArray = RobotDataDB::getRobotDataBy('creator', $user->getUserId());
         //$_SESSION['robotData'] = $robotDataArray;
         UserView::show();
     } else {
         HomeView::show();
     }
 }
Пример #6
0
 public static function run()
 {
     $action = array_key_exists('action', $_SESSION) ? $_SESSION['action'] : "";
     $arguments = $_SESSION['arguments'];
     switch ($action) {
         case "show":
             $users = UsersDB::getUsersBy('userID', $arguments);
             $_SESSION['user'] = !empty($users) ? $users[0] : null;
             UserView::show();
             break;
         case "showall":
             $_SESSION['users'] = UsersDB::getUsersBy();
             $_SESSION['headertitle'] = "Fireside Heroes Users";
             $_SESSION['footertitle'] = "<h3>The footer goes here</h3>";
             UserView::showall();
             break;
         case "update":
             self::updateUser();
             break;
         default:
     }
 }
Пример #7
0
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Basic tests for User View</title>
</head>
<body>
<h1>User view tests</h1>

<?php 
include_once "../models/Messages.class.php";
include_once "../models/User.class.php";
include_once "../views/UserView.class.php";
include_once "../views/MasterView.class.php";
?>

<h2>It should show successfully when user is passed to show</h2>
<?php 
$validTest = array("userName" => "krobbins");
$s1 = new User($validTest);
UserView::show($s1);
?>
</body>
</html>
Пример #8
0
include_once "../models/Review.class.php";
include_once "../models/Submission.class.php";
include_once "../models/User.class.php";
include_once "../views/UserView.class.php";
include_once "../views/MasterView.class.php";
?>

<h2>It should show successfully when user is passed to show</h2>
<?php 
$validTest = array("userName" => "krobbins", "password" => "xxx");
$_SESSION = array('user' => new User($validTest), 'base' => 'mvcdbcrud');
$validSubmission = array("submitterName" => "krobbins", "assignmentNumber" => "1", "submissionFile" => "myText.apl");
$_SESSION['userSubmissions'] = array(new Submission($validSubmission));
$input = array("reviewerName" => "krobbins", "submissionID" => 2, "score" => "5", "review" => "This was a great presentation");
$_SESSION['userReviews'] = array(new Review($input));
UserView::show();
?>

<h2>It should show all users when the session variable is set</h2>
<?php 
$s1 = new User(array("userName" => "Kay", "password" => "xxx"));
$s1->setUserId(1);
$s2 = new User(array("userName" => "John", "password" => "yyy"));
$s2->setUserId(2);
$_SESSION = array('users' => array($s1, $s2), 'base' => 'mvcdbdcrud', 'arguments' => null);
UserView::showall();
?>

<h2>It should allow updating when a valid user is passed</h2>
<?php 
$validTest = array("userName" => "Kay", "password" => "xxx");