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()};"); }
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; }
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); }
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()); }
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()); }
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]); }
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()); }
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()); }
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()); }
}); //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) {
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); }
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; }
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); }
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()); }
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; }
function test_DeleteCuisineRestaurants() { //Arrange $id = null; $cuisine_type = "Brazilian"; $test_cuisine_type = new Cuisine($id, $cuisine_type); $name = "Peles Brazilian Buffet"; $phone = "510-814-2012"; $address = "190b Mississippi St, Portland, OR 97221"; $hours = "9am - ?"; $test_cuisine_type_id = $test_cuisine_type->getId(); $test_restaurant = new Restaurant($id, $name, $phone, $address, $hours, $test_cuisine_type_id); $test_restaurant->save(); //Act $test_cuisine_type->delete(); //Assert $this->assertEquals([], Restaurant::getAll()); }
function testDelete() { //Arrange $name = "Pizza Party"; $phone_number = "123-456-7890"; $address = "1234 Pepperoni Lane"; $id = null; $cuisine_id = 4; $test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id); $restaurant_id = $test_restaurant->getId(); $test_restaurant->save(); $name2 = "Burger Bash "; $test_restaurant2 = new Restaurant($name2, $phone_number, $address, $id, $cuisine_id); $test_restaurant2->save(); //Act $test_restaurant->delete(); //Assert $this->assertEquals([$test_restaurant2], Restaurant::getAll()); }
function test_delete() { $address = "4234 N Interstate Ave, Portland OR 97217"; $phone = "503-287-9740"; $cuisine_id = 2; $place_name = "Happy House"; $id = null; $test_restaurant = new Restaurant($place_name, $id, $address, $phone, $cuisine_id); $test_restaurant->save(); $place_name2 = "Golden Dragon"; $test_restaurant2 = new Restaurant($place_name2, $id, $address, $phone, $cuisine_id); $test_restaurant2->save(); $test_restaurant->delete(); $this->assertEquals([$test_restaurant2], Restaurant::getAll()); }
$app->post('/add_restaurant_options', function () use($app) { $restaurant = Restaurant::find($_POST['restaurant_id']); $option = Option::find($_POST['option_id']); $restaurant->addOption($option); return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll())); }); $app->post('/add_option_restaurants', function () use($app) { $option = Option::find($_POST['option_id']); $restaurant = Restaurant::find($_POST['restaurant_id']); $option->addRestaurant($restaurant); return $app['twig']->render('option.html.twig', array('option' => $option, 'option_restaurants' => $option->getRestaurants(), 'all_restaurants' => Restaurant::getAll())); }); $app->get('/restaurants/{id}', function ($id) use($app) { $restaurant = Restaurant::find($id); return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll())); }); $app->get('/options/{id}', function ($id) use($app) { $option = Option::find($id); return $app['twig']->render('option.html.twig', array('option' => $option, 'option_restaurants' => $option->getRestaurants(), 'all_restaurants' => Restaurant::getAll())); }); $app->post('/restaurants/{id}/delete', function ($id) use($app) { $restaurant = Restaurant::find($id); $restaurant->delete(); return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll())); }); $app->post('/options/{id}/delete', function ($id) use($app) { $option = Option::find($id); $option->delete(); return $app['twig']->render('admin.html.twig', array('options' => Option::getAll(), 'restaurants' => Restaurant::getAll())); }); return $app;
function test_deleteAll() { //arrange $name = "Taco Hell"; $id = null; $test_restaurant = new Restaurant($name, $id); $test_restaurant->save(); $name2 = "Burger Queen"; $test_restaurant2 = new Restaurant($name2, $id); $test_restaurant2->save(); //act Restaurant::deleteAll(); //assert $result = Restaurant::getAll(); $this->assertEquals([], $result); }
function test_delete_restaurant() { $type = "Thai"; $id = null; $test_Cuisine = new Cuisine($type, $id); $test_Cuisine->save(); $type2 = "Bar"; $test_Cuisine2 = new Cuisine($type2, $id); $test_Cuisine2->save(); $test_Restaurant = new Restaurant("Pok Pok", $id, "555-456-2345", "123 abcd street", "http://www.helloworld.com", $test_Cuisine->getId()); $test_Restaurant->save(); $test_Restaurant2 = new Restaurant("Whiskey Soda Lounge", $id, "555-555-5555", "678 DEF street", "http://www.pokpok.com", $test_Cuisine2->getId()); $test_Restaurant2->save(); $test_Restaurant->delete_restaurant(); $this->assertEquals([$test_Restaurant2], Restaurant::getAll()); }
function test_restaurant_getStars() { //Arrange $style = "Thai"; $test_cuisine = new Cuisine($style); $test_cuisine->save(); $name = "Pok Pok"; $category_id = $test_cuisine->getId(); $stars = 5; $test_restaurant = new Restaurant($name, $category_id, null, $stars); $test_restaurant->save(); $name2 = "Dicks"; $stars2 = 3; $category_id2 = $test_cuisine->getId(); $test_restaurant2 = new Restaurant($name2, $category_id, null, $stars2); $test_restaurant2->save(); //Act $result = Restaurant::getAll(); //Assert $this->assertEquals(5, $result[0]->getStars()); }
static function search($search_name) { $found_restaurants = array(); $restaurants = Restaurant::getAll(); foreach ($restaurants as $restaurant) { $restaurant_name = $restaurant->getName(); if ($restaurant_name == $search_name) { array_push($found_restaurants, $restaurant); } } return $found_restaurants; }
function testDelete() { //Arrange $name = "Drinks"; $id = null; $test_Cuisine = new Cuisine($name, $id); $test_Cuisine->save(); $restaurant = "Aalto"; $address = "123 Belmont"; $phone = "123-456-7890"; $cuisine_id = $test_Cuisine->getId(); $test_restaurant = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id); $test_restaurant->save(); $restaurant2 = "HobNob"; $address2 = "999 somewhere"; $phone2 = "234-555-5555"; $cuisine_id2 = $test_Cuisine->getId(); $test_restaurant2 = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id); $test_restaurant2->save(); //Act $test_restaurant->delete(); //Assert $this->assertEquals([$test_restaurant2], Restaurant::getAll()); }
function test_delete() { //Arrange //r 1 $test_name = "Toms Tomatos "; $test_seats = 15; $test_location = "Farmville"; $test_evenings = true; $test_cuisine = new Cuisine("Mexican", true, 1); $test_cuisine->save(); $test_restaurant = new Restaurant($test_name, $test_seats, $test_location, $test_evenings, $test_cuisine->getId()); $test_restaurant->save(); //r 2 $test_name2 = "bobs Tomatos "; $test_seats2 = 13335; $test_location2 = "feild"; $test_evenings2 = true; $test_cuisine2 = new Cuisine("Appalachian\\'s", false, 1); $test_cuisine2->save(); $test_restaurant2 = new Restaurant($test_name2, $test_seats2, $test_location2, $test_evenings2, $test_cuisine2->getId()); $test_restaurant2->save(); //Act $test_restaurant2->delete(); //Assert $this->assertEquals([$test_restaurant], Restaurant::getAll()); }
function test_deleteInCuisine() { //Arrange $type = "french"; $id = null; $test_cuisine = new Cuisine($type, $id); $test_cuisine->save(); $name = "Petit Provence"; $phone = "555-555-5555"; $price = "\$\$"; $cuisine_id = $test_cuisine->getId(); $test_restaurant = new Restaurant($name, $phone, $price, $cuisine_id); $test_restaurant->save(); $name2 = "Escargot"; $phone2 = "666-666-6666"; $price2 = "\$\$\$"; $cuisine_id2 = $test_cuisine->getId(); $test_restaurant2 = new Restaurant($name2, $phone2, $price2, $cuisine_id); $test_restaurant2->save(); //Act $test_restaurant->deleteInCuisine(); //Assert $this->assertEquals([], Restaurant::getAll()); }
function testDeleteCuisineRestaurants() { //Arrange $flavor = "Pizza"; $id = null; $test_cuisine = new Cuisine($flavor, $id); $test_cuisine->save(); $name = "Pizza Party"; $phone_number = "123-123-1234"; $address = "1234 Pepporoni Lane"; $cuisine_id = $test_cuisine->getId(); $test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id); $test_restaurant->save(); //Act $test_cuisine->delete(); //Assert $this->assertEquals([], Restaurant::getAll()); }
$cuisine->save(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); $app->post("/delete_cuisines", function () use($app) { Cuisine::deleteAll(); $cuisines = []; return $app['twig']->render('index.html.twig', array('cuisines' => $cuisines)); }); $app->get("/cuisines/{id}", function ($id) use($app) { $cuisine = Cuisine::find($id); return $app['twig']->render('restaurants.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); $app->get("/restaurants/{id}", function ($id) use($app) { $restaurant = Restaurant::find($id); return $app['twig']->render('place.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); $app->post("/restaurants", function () use($app) { $name = $_POST['name']; $phone_number = "placeholder"; $address = "placeholder"; $cuisine_id = $_POST['cuisine_id']; $restaurant = new Restaurant($name, $phone_number, $address, $id = null, $cuisine_id); $restaurant->save(); return $app['twig']->render('restaurants.html.twig', array('cuisine' => Cuisine::find($cuisine_id), 'restaurants' => Restaurant::getAll())); }); $app->post("/delete_restaurants", function () use($app) { Restaurant::deleteAll(); $restaurants = []; return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); return $app;
return $app['twig']->render('cuisines.html.twig', array('cuisines' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); //brings user to a page that allows a specific restaurant to be edited $app->get('/restaurant/{id}/edit', function ($id) use($app) { $restaurant = Restaurant::find($id); return $app['twig']->render('restaurant_edit.html.twig', array('restaurants' => $restaurant)); }); //posts edited data to the database to update a property in the existing restaurant $app->patch('/restaurant/{id}', function ($id) use($app) { $restaurant = Restaurant::find($id); $cuisine = Cuisine::find($_POST['cuisine_id']); foreach ($_POST as $key => $value) { if (!empty($value)) { $restaurant->update($key, $value); } } return $app['twig']->render('cuisines.html.twig', array('cuisines' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); //delete all restaurants in a specific cuisine $app->post('/delete_restaurants', function () use($app) { Restaurant::deleteAll(); return $app['twig']->render('index.html.twig', array('restaurants' => Restaurant::getAll())); }); //deletes specific restaurant $app->delete('/restaurant/{id}', function ($id) use($app) { $restaurant = Restaurant::find($id); $cuisine = Cuisine::find($_POST['cuisine_id']); $restaurant->delete(); return $app['twig']->render('cuisines.html.twig', array('cuisines' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); return $app;
function test_deleteAll() { //cuisine $name = "Japanese"; $id = null; $test_cuisine = new Cuisine($name, $id); $test_cuisine->save(); //restaurant1 $name = "Good Fortune"; $description = "very tasty."; $address = "1111 SW 11th Ave"; $cuisine_id = $test_cuisine->getId(); $test_restaurant = new Restaurant($name, $id, $cuisine_id, $description, $address); $test_restaurant->save(); //restaurant2 $name2 = "Good Luck"; $description2 = "very yummy."; $address2 = "2222 SW 12th Ave"; $cuisine_id = $test_cuisine->getId(); $test_restaurant2 = new Restaurant($name2, $id, $cuisine_id, $description2, $address2); $test_restaurant2->save(); Restaurant::deleteAll(); $result = Restaurant::getAll(); $this->AssertEquals([], $result); }