本文整理汇总了PHP中Restaurant::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::getAll方法的具体用法?PHP Restaurant::getAll怎么用?PHP Restaurant::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
function delete()
{
$restaurants = Restaurant::getAll();
foreach ($restaurants as $restaurant) {
if ($restaurant->getCuisineId() == $this->getId()) {
$restaurant->delete();
}
}
$GLOBALS['DB']->exec("DELETE FROM cuisines WHERE id = {$this->getId()};");
}
示例2: find
static function find($restaurant_id)
{
$found_restaurant = null;
$restaurants = Restaurant::getAll();
foreach ($restaurants as $restaurant) {
if ($restaurant->getId() == $restaurant_id) {
$found_restaurant = $restaurant;
}
}
return $found_restaurant;
}
示例3: test_getAll
function test_getAll()
{
//Arrange
$restaurant_name = "Antoons";
$cuisine_type = 1;
$restaurant_phone = "4128675309";
$restaurant_address = "123 Atwood St";
$test_Restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address);
$test_Restaurant->save();
$restaurant_name = "Spankys";
$cuisine_type = 2;
$restaurant_phone = "8015715713";
$restaurant_address = "379 E 3333 S";
$test_next_Restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address);
$test_next_Restaurant->save();
//Act
$result = Restaurant::getAll();
//Assert
$this->assertEquals([$test_Restaurant, $test_next_Restaurant], $result);
}
示例4: testDelete
function testDelete()
{
//Arrange
$restaurant_name = "McDonalds";
$id = null;
$test_restaurant = new Restaurant($restaurant_name, $id);
$test_restaurant->save();
$restaurant_name2 = "Joes Burgers";
$test_restaurant2 = new Restaurant($restaurant_name2, $id);
$test_restaurant2->save();
//Act
$test_restaurant->deleteOne();
//Assert
$this->assertEquals([$test_restaurant2], Restaurant::getAll());
}
示例5: test_cuisine_delete
function test_cuisine_delete()
{
$style = "Thai";
$test_cuisine = new Cuisine($style);
$test_cuisine->save();
$style2 = "burgers";
$test_cuisine2 = new Cuisine($style2);
$test_cuisine2->save();
$name = "Pok Pok";
$category_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $category_id);
$test_restaurant->save();
$name2 = "Dicks";
$category_id2 = $test_cuisine2->getId();
$test_restaurant2 = new Restaurant($name2, $category_id2);
$test_restaurant2->save();
//Act
$test_cuisine->delete();
//Assert
$this->assertEquals([$test_restaurant2], Restaurant::getAll());
}
示例6: test_delete
function test_delete()
{
$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();
$test_restaurant->delete();
$result = Restaurant::getAll();
$this->assertEquals($test_restaurant2, $result[0]);
}
示例7: test_deleteCuisineRestaurants
function test_deleteCuisineRestaurants()
{
$type = "Mexican";
$id = null;
$test_Cuisine = new Cuisine($type, $id);
$test_Cuisine->save();
$name = "Por Que No";
$phone = "555-555-5555";
$address = "123 ABC street";
$website = "http://www.porqueno.com";
$cuisine_id = $test_Cuisine->getId();
$test_Restaurant = new Restaurant($name, $id, $phone, $address, $website, $cuisine_id);
$test_Restaurant->save();
$test_Cuisine->delete_cuisine();
$this->assertEquals([], Restaurant::getAll());
}
示例8: testDeleteCuisineRestaurants
function testDeleteCuisineRestaurants()
{
//Arrange
$name = "Italian";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$name = "Piazza Italia";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $id, $cuisine_id, $rating);
$test_restaurant->save();
//Act
$test_cuisine->delete();
//Assert
$this->assertEquals([], Restaurant::getAll());
}
示例9: test_DeleteCuisineRestaurants
function test_DeleteCuisineRestaurants()
{
//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();
//Act
$test_cuisine->delete();
//Assert
$this->assertEquals([], Restaurant::getAll());
}
示例10: function
});
//Save a new restaurant:
$app->post("/restaurants", function () use($app) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$price = $_POST['price'];
$cuisine_id = $_POST['cuisine_id'];
$restaurant = new Restaurant($name, $phone, $price, $cuisine_id);
$restaurant->save();
$cuisine = Cuisine::find($cuisine_id);
return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//View list of restaurants after save:
$app->get("/restaurants", function () use($app) {
$cuisine = Cuisine::find($cuisine_id);
return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => Restaurant::getAll()));
});
//Page for editing a cuisine:
$app->get("/cuisines/{id}/edit", function ($id) use($app) {
$cuisine = Cuisine::find($id);
return $app['twig']->render('cuisine_edit.html.twig', array('cuisine' => $cuisine));
});
//Update a cuisine form:
$app->patch("/cuisines/{id}", function ($id) use($app) {
$type = $_POST['type'];
$cuisine = Cuisine::find($id);
$cuisine->update($type);
return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//Edit a restaurant page:
$app->get("/restaurants/{id}/edit", function ($id) use($app) {
示例11: test_deleteAll
function test_deleteAll()
{
//Arrange
$name = "Italian";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$name = "Piazza Italia";
$rating = 1;
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $id, $cuisine_id, $rating);
$test_restaurant->save();
$name2 = "Ristorante Roma";
$rating = 1;
$test_restaurant2 = new Restaurant($name2, $id, $cuisine_id, $rating);
$test_restaurant2->save();
//Act
Restaurant::deleteAll();
//Assert
$result = Restaurant::getAll();
$this->assertEquals([], $result);
}
示例12: find_restaurant
static function find_restaurant($search_id)
{
$found_restaurant = array();
$restaurants = Restaurant::getAll();
foreach ($restaurants as $restaurant) {
$restaurant_id = $restaurant->getId();
if ($restaurant_id == $search_id) {
$found_restaurant = array($restaurant->getName(), $restaurant_id, $restaurant->getPhone(), $restaurant->getAddress(), $restaurant->getWebsite(), $restaurant->getCategoryId());
}
}
return $found_restaurant;
}
示例13: testDeleteAll
function testDeleteAll()
{
//Arrange
$type = "Italian";
$id = null;
$test_cuisine = new Cuisine($type, $id);
$test_cuisine->save();
$name = "City Chinese";
$description = "OK Chinese food";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($description, $id, $cuisine_id, $name);
$test_restaurant->save();
$name2 = "City Mexican";
$description2 = "OK Mexican food";
$test_restaurant2 = new Restaurant($description2, $id, $cuisine_id, $name2);
$test_restaurant2->save();
//Assert
Restaurant::deleteAll();
//Assert
$result = Restaurant::getAll();
$this->assertEquals([], $result);
}
示例14: test_Delete
function test_Delete()
{
//Arrange
$name = "American";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$restaurant_name = "VQ";
$phone = '5032277342';
$address = "1220 SW 1st Ave, Portland, OR 97204";
$website = "http://www.veritablequandary.com/";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($restaurant_name, $phone, $address, $website, $cuisine_id);
$test_restaurant->save();
$restaurant_name2 = "Hot Lips Pizza";
$phone2 = '5035952342';
$address2 = "721 NW 9th Ave #150, Portland, OR 97209";
$website2 = "http://hotlipspizza.com/";
$test_restaurant2 = new Restaurant($restaurant_name2, $phone2, $address2, $website2, $cuisine_id);
$test_restaurant2->save();
//Act
$test_restaurant->delete();
//Assert
$this->assertEquals([$test_restaurant2], Restaurant::getAll());
}
示例15: findRestaurantName
static function findRestaurantName($search_restaurant)
{
$found_restaurants = array();
$restaurants = Restaurant::getAll();
foreach ($restaurants as $restaurant) {
$restaurant_name = $restaurant->getName();
if (strpos(strtolower($restaurant_name), strtolower($search_restaurant)) !== false) {
array_push($found_restaurants, $restaurant);
}
}
return $found_restaurants;
}