Ejemplo n.º 1
0
 function test_getReviews()
 {
     $unisex = 0;
     $key_required = 0;
     $public = 0;
     $handicap = 0;
     $changing_table = 0;
     $marker_id = 2;
     $test_bathroom = new Bathroom($unisex, $key_required, $public, $handicap, $changing_table, $marker_id);
     $test_bathroom->save();
     $rating = 1;
     $comment = "This place sucks!";
     $test_review = new Review($rating, $comment);
     $test_review->save();
     $rating2 = 3;
     $comment2 = "Its aight!";
     $test_review2 = new Review($rating2, $comment2);
     $test_review2->save();
     $test_bathroom->addReview($test_review->getId());
     $test_bathroom->addReview($test_review2->getId());
     $result = $test_bathroom->getReviews();
     $this->assertEquals([$test_review, $test_review2], $result);
 }
Ejemplo n.º 2
0
 static function find_bathroom($search_id)
 {
     $found_bathroom = array();
     $bathrooms = Bathroom::getAll();
     foreach ($bathrooms as $bathroom) {
         $bathroom_id = $bathroom->getId();
         if ($bathroom_id == $search_id) {
             $found_bathroom = array($bathroom->getunisex, $bathroom->getkey_required(), $bathroom->getpublic(), $bathroom->getHandicap, $bathroom->getpublic());
         }
     }
     return $found_bathroom;
 }
Ejemplo n.º 3
0
    $marker_id = $marker->getId();
    $bathroom = new Bathroom($unisex, $key_required, $public, $handicap, $changing_table, $marker_id);
    $bathroom->save();
    return $app['twig']->render('add_bathroom.html.twig', array('bathrooms' => Bathroom::getAll(), 'markers' => Marker::getAll(), 'form_check' => false));
});
$app->get('/bathroom/{id}', function ($id) use($app) {
    $bathroom = Bathroom::find($id);
    $marker = Marker::find($id);
    $reviews = Review::getReviewsForBathroom($bathroom);
    return $app['twig']->render('bathroom.html.twig', array('bathroom' => $bathroom, 'marker' => $marker, 'reviews' => $reviews));
});
// reviews
$app->get('/add_review/{id}', function ($id) use($app) {
    $marker = Marker::find($id);
    return $app['twig']->render('add_review.html.twig', array('marker' => $marker));
});
$app->post('/add_review/{id}', function ($id) use($app) {
    $review = $_POST['review'];
    $rating = $_POST['rating'];
    //get all the necessary objects
    $marker = Marker::find($id);
    $bathroom = Bathroom::find($marker->getId());
    //create new review obj
    $new_review = new Review($rating, $review);
    $new_review->save();
    $review_id = $new_review->getId();
    $bathroom->addReview($review_id);
    $reviews = Review::getReviewsForBathroom($bathroom);
    return $app['twig']->render('bathroom.html.twig', array('bathroom' => $bathroom, 'marker' => $marker, 'reviews' => $reviews));
});
return $app;