本文整理汇总了PHP中Review::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::getAll方法的具体用法?PHP Review::getAll怎么用?PHP Review::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Review
的用法示例。
在下文中一共展示了Review::getAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
function delete()
{
$reviews = Review::getAll();
foreach ($reviews as $review) {
if ($review->getRestaurantId() == $this->getId()) {
$review->delete();
}
}
$GLOBALS['DB']->exec("DELETE FROM restaurants WHERE id = {$this->getId()};");
}
示例2: find
static function find($search_id)
{
$found_review = null;
$reviews = Review::getAll();
foreach ($reviews as $review) {
$review_id = $review->getId();
if ($review_id == $search_id) {
$found_review = $review;
}
}
return $found_review;
}
示例3: test_getAll
function test_getAll()
{
//Arrange
$review = "Pizza was dope";
$restaurant_id = 1;
$test_review = new Review($review, $restaurant_id);
$test_review->save();
$review2 = "DAMN DAT GRILLED CHEESE IS FIRE";
$restaurant_id2 = 2;
$test_review2 = new Review($review2, $restaurant_id2);
$test_review2->save();
//Act
$result = Review::getAll();
//Assert
$this->assertEquals([$test_review, $test_review2], $result);
}
示例4: test_save
function test_save()
{
$restaurant = new Restaurant("Pok Pok", 2, "5", "1", "website", 2);
$name = "Bob";
$id = null;
$rating = 3;
$review_text = "B";
$review_date = "2015-10-10";
$restaurant_id = $restaurant->getId();
$test_Review = new Review($name, $id, $rating, $review_text, $review_date, $restaurant_id);
$test_Review->save();
$result = Review::getAll();
$this->assertEquals($test_Review, $result[0]);
}
示例5: test_deleteReviews
function test_deleteReviews()
{
$name = "Asian";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$restaurant_name = "The Golden Duck";
$location = "898 SW 5th Ave, Portland, OR";
$description = "A Chill Asian experince";
$price = "\$\$";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($restaurant_name, $location, $description, $price, $cuisine_id);
$test_restaurant->save();
$restaurant_name2 = "The Red Dragon";
$location2 = "899 SW 5th Ave, Portland, OR";
$description2 = "A Intense Asian experince";
$price2 = "\$\$\$";
$cuisine_id2 = $test_cuisine->getId();
$test_restaurant2 = new Restaurant($restaurant_name2, $location2, $description2, $price2, $cuisine_id2);
$test_restaurant2->save();
$user = "yoloswag1959";
$stars = 3;
$headline = "It is aight.";
$body = "Yeah, pretty aight bro";
$restaurant_id = $test_restaurant->getId();
$test_review = new Review($user, $stars, $headline, $body, $restaurant_id);
$test_review->save();
$user2 = "6969babygirl";
$stars2 = 3;
$headline2 = "XOXO";
$body2 = "I cant even";
$restaurant_id2 = $test_restaurant->getId();
$test_review2 = new Review($user2, $stars2, $headline2, $body2, $restaurant_id2);
$test_review2->save();
$test_restaurant->delete();
$result = Review::getAll();
//var_dump($result);
$this->assertEquals([], $result);
}
示例6: test_deleteAll
function test_deleteAll()
{
//Arrange
$beer_id = 1;
$user_id = 1;
$review = "Great beer";
$date = "2015-10-08";
$id = 3;
$test_review = new Review($beer_id, $user_id, $review, $date, $id);
$test_review->save();
//Act
$test = Review::deleteAll();
$result = Review::getAll();
//Assert
$this->assertEquals([], $result);
}
示例7: test_DeleteCuisineRestaurantsReviews
function test_DeleteCuisineRestaurantsReviews()
{
//Arrange
//cuisine
$name = "Japanese";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
//restaurant
$name = "Good Fortune";
$cuisine_id = $test_cuisine->getId();
$description = "very tasty.";
$address = "1111 SW 11th Ave";
$test_restaurant = new Restaurant($name, $id, $cuisine_id, $description, $address);
$test_restaurant->save();
//review
$username = "Ben";
$date = 00 - 00 - 00;
$rating = 5;
$comment = "good one.";
$restaurant_id = $test_restaurant->getId();
$test_review = new Review($username, $date, $rating, $comment, $restaurant_id, $id);
//Act
$test_cuisine->delete();
//Assert
$this->assertEquals([], Review::getAll());
}
示例8: test_deleteAll
function test_deleteAll()
{
//Arrange
$rating = 1;
$comment = "This place sucks!";
$id = null;
$test_review = new Review($rating, $comment, $id);
$test_review->save();
$rating2 = 2;
$comment2 = "This place smells!";
$id2 = null;
$test_review2 = new Review($rating2, $comment2, $id2);
$test_review2->save();
//Act
Review::deleteAll();
//Assert
$result = Review::getAll();
$this->assertEquals([], $result);
}
示例9: array
$restaurant->save();
$cuisine = Cuisine::find($cuisine_id);
return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//Reviews page
$app->get("/restaurants/{id}", function ($id) use($app) {
$restaurant = Restaurant::find($id);
return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'reviews' => $restaurant->getReviews()));
});
$app->post("/reviews", function () use($app) {
$username = $_POST['username'];
$date = $_POST['date'];
$rating = $_POST['rating'];
$comment = $_POST['comment'];
$restaurant_id = $_POST['restaurant_id'];
$review = new Review($username, $date, $rating, $comment, $restaurant_id, $id = null);
$review->save();
$restaurant = Restaurant::find($restaurant_id);
return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'reviews' => Review::getAll()));
});
//Cuisine_edit page
$app->get("/cuisines/{id}/edit", function ($id) use($app) {
$cuisine = Cuisine::find($id);
return $app['twig']->render('cuisine_edit.html.twig', array('cuisine' => $cuisine));
});
//Search result page
$app->get("/search", function () use($app) {
$search = Restaurant::search($_GET['search']);
return $app['twig']->render('search.html.twig', array('search' => $search, 'search_term' => $_GET['search']));
});
return $app;