function test_find() { $cuisine_name = "Italian"; $cuisine_name2 = "Chinese"; $test_cuisine = new Cuisine($cuisine_name); $test_cuisine->save(); $test_cuisine2 = new Cuisine($cuisine_name2); $test_cuisine2->save(); $result = Cuisine::find($test_cuisine->getId()); $this->assertEquals($test_cuisine, $result); }
function test_find() { $type = "Mexican"; $type2 = "Italian"; $test_Cuisine = new Cuisine($type); $test_Cuisine->save(); $test_Cuisine2 = new Cuisine($type2); $test_Cuisine2->save(); $result = Cuisine::find($test_Cuisine->getId()); $this->assertEquals($test_Cuisine, $result); }
function test_cuisine_find() { //Arrange $cuisine1 = new Cuisine("Thai"); $cuisine1->save(); $cuisine2 = new Cuisine("Dogfood"); $cuisine2->save(); //Act $id = $cuisine1->getId(); $result = Cuisine::find($id); //Assert $this->assertEquals($cuisine1, $result); }
return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); $app->get("/cuisines/{id}", function ($id) use($app) { $cuisine = Cuisine::find($id); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); $app->post("/cuisines", function () use($app) { $cuisine = new Cuisine($_POST['name']); $cuisine->save(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); $app->post("/delete_cuisines", function () use($app) { Cuisine::deleteAll(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); $app->get("/cuisines/{id}/edit", function ($id) use($app) { $cuisine = Cuisine::find($id); return $app['twig']->render('cuisine_edit.html.twig', array('cuisine' => $cuisine)); }); $app->patch("/cuisines/{id}", function ($id) use($app) { $name = $_POST['name']; $cuisine = Cuisine::find($id); $cuisine->update($name); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); $app->delete("/cuisines/{id}", function ($id) use($app) { $cuisine = Cuisine::find($id); $cuisine->delete(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); return $app;
Cuisine::deleteAll(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll(), 'cuisine_check' => false, 'venue_check' => false)); }); //Navigate to cuisine page $app->get('/cuisines/{id}', function ($id) use($app) { $cuisine = Cuisine::find($id); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues())); }); //Create a new venue $app->post('/venues', function () use($app) { $name = $_POST['name']; $cuisine_id = $_POST['cuisine_id']; $description = $_POST['description']; $address = $_POST['address']; $rating = $_POST['rating']; $venue = new Venue($name, $cuisine_id, $id = null, $rating, $address, $description); $venue->save(); $cuisine = Cuisine::find($cuisine_id); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues())); }); // Delete a single venue from a cuisine // $app->delete('/cuisine/{id}', function($id) use ($app) { // $venues = Venue::find($id); // foreach($venues as $venue) { // $venue // } // $venue->deleteVenue(); // $cuisine = Cuisine::find($id); // return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues())); // }); return $app;
}); //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) { $restaurant = Restaurant::find($id); $cuisine = Cuisine::find($restaurant->getCuisineId()); return $app['twig']->render('restaurant_edit.html.twig', array('restaurant' => $restaurant, 'cuisine' => $cuisine)); }); //Show cuisine page with update restaurant: $app->patch("/restaurants/{id}", function ($id) use($app) { $name = $_POST['name']; $phone = $_POST['phone']; $price = $_POST['price']; $restaurant = Restaurant::find($id); $restaurant->update($name, $phone, $price); $cuisine = Cuisine::find($restaurant->getCuisineId()); return $app['twig']->render('cuisine.html.twig', array('restaurant' => $restaurant, 'cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); //Clear all items in database (cuisines AND restaurants): $app->post("/delete_cuisines", function () use($app) { Restaurant::deleteAll(); Cuisine::deleteAll(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); return $app;
$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;
function test_find() { //Arrange $name = "American"; $name2 = "Italian"; $test_cuisine = new Cuisine($name); $test_cuisine->save(); $test_cuisine2 = new Cuisine($name2); $test_cuisine2->save(); //Act $result = Cuisine::find($test_cuisine->getId()); //Assert $this->assertEquals($test_cuisine, $result); }
function test_find() { //Arrange $restaurant_name = "McDonalds"; $id = null; $test_restaurant = new Restaurant($restaurant_name, $id); $test_restaurant->save(); $cuisine_name = "Tacos"; $restaurant_id = $test_restaurant->getId(); $test_cuisine = new Cuisine($cuisine_name, $id, $restaurant_id); $test_cuisine->save(); $cuisine_name2 = "Tacos2"; $restaurant_id2 = $test_restaurant->getId(); $test_cuisine2 = new Cuisine($cuisine_name2, $id, $restaurant_id2); $test_cuisine2->save(); //Act $id = $test_cuisine->getId(); $result = Cuisine::find($id); //Assert $this->assertEquals($test_cuisine, $result); }
function test_find() { $type = "Mexican"; $type2 = "Southern"; $test_cuisine = new Cuisine($type); $test_cuisine->save(); $test_cuisine2 = new Cuisine($type2); $test_cuisine2->save(); $search_cuisine = $test_cuisine->getId(); $result = Cuisine::find($search_cuisine); $this->assertEquals($test_cuisine, $result); }
function test_find() { //Arrange $id = null; $cuisine_type = "Italian"; $test_cuisine_type = new Cuisine($id, $cuisine_type); $test_cuisine_type->save(); $id2 = null; $cuisine_type2 = "Mexican"; $test_cuisine_type2 = new Cuisine($id2, $cuisine_type2); $test_cuisine_type2->save(); //Act $result = Cuisine::find($test_cuisine_type->getId()); //Assert $this->assertEquals($test_cuisine_type, $result); }
$cuisine = new Cuisine($_POST['type']); $cuisine->save(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll(), 'form_check' => false)); }); //Delete all cuisines $app->post('/delete_cuisines', function () use($app) { Cuisine::deleteAll(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll(), 'form_check' => false)); }); //Navigate to cuisine page $app->get('/cuisines/{id}', function ($id) use($app) { $cuisine = Cuisine::find($id); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues(), 'form_check' => false)); }); //Create a new venue $app->post('/add_venue', function () use($app) { $name = $_POST['name']; $cuisine_id = $_POST['cuisine_id']; $description = $_POST['description']; $address = $_POST['address']; $rating = $_POST['rating']; $venue = new Venue($name, $cuisine_id, $id = null, $rating, $address, $description); $venue->save(); $cuisine = Cuisine::find($cuisine_id); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues(), 'form_check' => false)); }); $app->get('/form_restaurant', function () use($app) { $cuisine = Cuisine::find($_GET['cuisine_id']); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues(), 'form_check' => true)); }); return $app;
$cuisine->update($cuisine_name); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaraunts' => $cuisine->getRestaraunts())); }); $app->delete("/cuisines/{id}", function ($id) use($app) { $cuisine = Cuisine::find($id); $cuisine->delete(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); $app->get("/restaraunts/{id}", function ($id) use($app) { $restaraunt = Restaraunt::find($id); return $app['twig']->render('restaraunt.html.twig', array('restaraunt' => $restaraunt)); }); $app->get("/restaraunts/{id}/edit", function ($id) use($app) { $restaraunt = Restaraunt::find($id); return $app['twig']->render('restaraunt.html.twig', array('restaraunt' => $restaraunt)); }); $app->patch("/restaraunts/{id}", function ($id) use($app) { $restaraunt_name = $_POST['RestarauntName']; $restaraunt = Restaraunt::find($id); $cuisine = Cuisine::find($id); $restaraunt->update($restaraunt_name); return $app['twig']->render('restaraunt.html.twig', array('restaraunt' => $restaraunt)); }); $app->delete("/restaraunts/{id}", function ($id) use($app) { $restaraunt = Restaraunt::find($id); $cuisine = Cuisine::find($restaraunt->getCuisineId()); $restaraunt->delete(); $restaraunts = Restaraunt::getAll(); return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaraunts' => $restaraunts)); }); return $app;
function test_find() { //Arrange $type = "french"; $type2 = "mexican"; $test_cuisine = new Cuisine($type); $test_cuisine->save(); $test_cuisine2 = new Cuisine($type); $test_cuisine2->save(); //Act $result = Cuisine::find($test_cuisine->getId()); //Assert $this->assertEquals($test_cuisine, $result); }
function test_find() { //Arrange $name = "Pizza"; $name2 = "Burgers"; $test_Cuisine = new Cuisine($name); $test_Cuisine->save(); $test_Cuisine2 = new Cuisine($name2); $test_Cuisine2->save(); //Act $result = Cuisine::find($test_Cuisine->getId()); //Assert $this->assertEquals($test_Cuisine, $result); }
function test_find() { //Arrange $type = "Italian"; $type2 = "Japanese"; $test_cuisine = new Cuisine($type); $test_cuisine->save(); $test_cuisine2 = new Cuisine($type2); $test_cuisine2->save(); //Act $result = Cuisine::find($test_cuisine->getId()); //Assert $this->assertEquals($test_cuisine, $result); }
function test_update() { //Arrange $cuisine = "Pizza"; $test_cuisine = new Cuisine($cuisine); $test_cuisine->save(); //Act $result = Cuisine::find($test_cuisine->getID()); $result->setCuisineType("Burgers"); $result->update(); $result = $result->getCuisineType(); //Assert $this->assertEquals("Burgers", $result); }
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_find() { //arrange $type = "Tacos"; $type2 = "Greek"; $test_Cuisine = new Cuisine($type); $test_Cuisine->save(); $test_Cuisine2 = new Cuisine($type2); $test_Cuisine2->save(); //act $result = Cuisine::find($test_Cuisine->getId()); //assert $this->assertEquals($test_Cuisine, $result); }