Example #1
0
 public function getFields()
 {
     $this->loadLanguageFile('backend/Review');
     $this->loadLanguageFile('backend/Product');
     $controller = new ReviewController($this->application);
     foreach ($controller->getAvailableColumns() as $key => $data) {
         $fields[$key] = $this->translate($data['name']);
     }
     unset($fields['Product.name']);
     $groupedFields = $this->getGroupedFields($fields);
     $identify = array();
     foreach (array('ID', 'sku') as $field) {
         $field = 'Product.' . $field;
         $identify[$field] = $this->application->translate($field);
     }
     $groupedFields['Product'] = $identify;
     return $groupedFields;
 }
 public function testCallRunFromGet()
 {
     DBMaker::create('ptest1');
     Database::clearDB();
     $db = Database::getDB($dbName = 'ptest1', $configPath = "C:" . DIRECTORY_SEPARATOR . "xampp" . DIRECTORY_SEPARATOR . "myConfig.ini");
     $_SERVER["REQUEST_METHOD"] = "GET";
     ob_start();
     ReviewController::run();
     $output = ob_get_clean();
     $this->assertFalse(empty($output), "It should show something from a GET");
 }
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Basic tests for Login Controller</title>
</head>
<body>
<h1>Login controller tests</h1>

<?php 
include_once "../controllers/ReviewController.class.php";
include_once "../views/ReviewView.class.php";
?>

<h2>It should call the run method</h2>
<?php 
//$_SERVER ["REQUEST_METHOD"] = "POST";
//$_POST = array("firstName" => "Kay");
ReviewController::run();
?>
</body>
</html>
Example #4
0
<?php

//include('session.php');
include_once 'controller/user_controller.php';
include_once 'controller/book_controller.php';
include_once 'controller/review_controller.php';
include_once 'controller/read_controller.php';
include_once "searchbook.php";
include_once "approve.php";
include_once "del_book.php";
include_once "del_user.php";
include_once "save_book.php";
include_once "insertbook.php";
$userController = new UserController();
$bookController = new BookController();
$reviewController = new ReviewController();
$readController = new ReadingController();
?>

<!DOCTYPE html>
<html>
	<head>
		<title>E-Biblio. Online library. About</title>
		<meta charset="UTF-8">
		<link rel="stylesheet" href="css/foundation.min.css">
        <link rel="stylesheet" href="css/foundation.css">
		<link rel="stylesheet" href="css/custom.css">
		
		<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,800italic,300italic,400italic,600,600italic,700,700italic,800" rel="stylesheet">
		<link href="https://fonts.googleapis.com/css?family=Lato:400,100,100italic,300,300italic,400italic,700,700italic,900,900italic" rel="stylesheet">
		<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
    }
    public function get()
    {
        $this->vars->review = $this->getPerformanceReviewService()->buildPerformanceReview($this->reviewId);
        $this->vars->questions = $this->getPerformanceReviewService()->buildReviewQuestions($this->reviewId);
        $this->vars->answers = $this->getPerformanceReviewService()->buildReviewAnswers($this->reviewId);
        $this->renderTemplate('review.php');
    }
    public function post()
    {
        //do form validation, what does that mean?
        try {
            //This line is perhaps the one I'm least confident in.
            //We need this object. I'm not sure exactly the best way to build it, and how
            //much validation happens when you build it. In the end, it just needs to
            //implement the right interface for the operation we're performing later.
            $reviewAnswers = new PerformanceReviewAnswersRequest($this->reviewId, $_POST['questions']);
        } catch (InvalidArgumentException $exception) {
            //invalid data posted.
            Session::message("I'm sorry, you did it wrong.");
            $this->redirect("review.php?id=" . $this->reviewId);
        }
        $this->getPerformanceReviewService()->answerReviewQuestions($reviewAnswers);
        if ($_POST['action'] == 'submit') {
            $this->getPerformanceReviewService()->submitPerformanceReview($this->reviewId, new DateTime(null, new DateTimeZone('UTC')));
        }
        $this->redirect("review.php?id=" . $this->reviewId);
    }
}
$controller = new ReviewController(new PerformanceReviewServiceMock());
$controller->dispatch();