function test_cuisine_save() { //Arrange $style = "Thai"; $test_cuisine = new Cuisine($style); //Act $test_cuisine->save(); //Assert $result = Cuisine::getAll(); $this->assertEquals($test_cuisine, $result[0]); }
function test_getAll() { //Arrange $cuisine = "Pizza"; $test_cuisine = new Cuisine($cuisine); $test_cuisine->save(); //Act $result = Cuisine::getAll(); //Assert $this->assertEquals([$test_cuisine], $result); }
static function search($search_type) { $found_cuisine = null; $cuisines = Cuisine::getAll(); foreach ($cuisines as $cuisine) { $cuisine_type = $cuisine->getCuisineType(); if ($cuisine_type == $search_type) { $found_cuisine_type = $cuisine; } } return $found_cuisine_type; }
function test_deleteAll() { $type = "Chinese"; $type2 = "American"; $test_cuisine = new Cuisine($type); $test_cuisine->save(); $test_cuisine2 = new Cuisine($type2); $test_cuisine2->save(); Cuisine::deleteAll(); $result = Cuisine::getAll(); $this->assertEquals([], $result); }
static function find($search_id) { $found_cuisine = null; $cuisines = Cuisine::getAll(); foreach ($cuisines as $cuisine) { $cuisine_id = $cuisine->getId(); if ($cuisine_id == $search_id) { $found_cuisine = $cuisine; } } return $found_cuisine; }
function test_deleteAll() { //Arrange $id = null; $cuisine_type = "Italian"; $test_cuisine = new Cuisine($id, $cuisine_type); $test_cuisine->save(); $id2 = null; $cuisine_type2 = "Korean"; $test_cuisine2 = new Cuisine($id2, $cuisine_type2); $test_cuisine2->save(); //Act Cuisine::deleteAll(); //Assert $result = Cuisine::getAll(); $this->assertEquals([], $result); }
function test_delete() { //arrange $type = "Tacos"; $id = null; $test_cuisine = new Cuisine($type, $id); $test_cuisine->save(); $type2 = "Greek"; $test_cuisine2 = new Cuisine($type2, $id); $test_cuisine2->save(); //act $test_cuisine->delete(); //assert $this->assertEquals([$test_cuisine2], Cuisine::getAll()); }
$app->patch("/cuisines/{id}", function ($id) use($app) { $name = $_POST['name']; $cuisine = Cuisine::find($id); $cuisine->update($name); return $app['twig']->render('cuisines.html.twig', array('cuisines' => $cuisine, 'restaurants' => $cuisine->getRestaurants())); }); //deletes one specific cuisine $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())); }); //clear database of all cuisines $app->post('/delete_cuisines', function () use($app) { Cuisine::deleteAll(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll())); }); //creates new restaurants and displays them on the same page $app->post('/restaurants', function () use($app) { //takes the input values and builds a new restaurant and saves restaurant to database $restaurant_name = $_POST['restaurant_name']; $phone = $_POST['phone']; $address = $_POST['address']; $website = $_POST['website']; $cuisine_id = $_POST['cuisine_id']; $restaurant = new Restaurant($restaurant_name, $phone, $address, $website, $cuisine_id); $restaurant->save(); $cuisine = Cuisine::find($cuisine_id); 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
function testDelete() { //Arrange $cuisine_name = "Italian"; $id = null; $test_cuisine = new Cuisine($cuisine_name, $id); $test_cuisine->save(); $cuisine_name2 = "Chinese"; $test_cuisine2 = new Cuisine($cuisine_name2, $id); $test_cuisine2->save(); //Act $test_cuisine->delete(); //Assert $this->assertEquals([$test_cuisine2], Cuisine::getAll()); }
function test_delete() { //Arrange $type = "Italian"; $id = null; $test_cuisine = new Cuisine($type, $id); $test_cuisine->save(); $type2 = "Thai"; $id = null; $test_cuisine2 = new Cuisine($type, $id); $test_cuisine2->save(); //Act $test_cuisine->deleteCuisine(); //Assert $this->assertEquals([$test_cuisine2], Cuisine::getAll()); }
function testDelete() { //Arrange $flavor = "Pizza"; $id = null; $test_cuisine = new Cuisine($flavor, $id); $test_cuisine->save(); $flavor2 = "Burgers"; $test_cuisine2 = new Cuisine($flavor2, $id); $test_cuisine2->save(); //Act $test_cuisine->delete(); //Assert $this->assertEquals([$test_cuisine2], Cuisine::getAll()); }
return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll(), 'cuisine_check' => true, 'venue_check' => false)); }); //Venue form view $app->get("/form-venue", function () use($app) { return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll(), 'cuisine_check' => false, 'venue_check' => true)); }); //Submit cuisine $app->post('/add_cuisine', function () use($app) { $cuisine = new Cuisine($_POST['type']); $cuisine->save(); return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll(), 'cuisine_check' => false, 'venue_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(), '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();
function test_delete() { $type = "Mexican"; $id = null; $test_Cuisine = new Cuisine($type, $id); $test_Cuisine->save(); $type2 = "Italian"; $test_Cuisine2 = new Cuisine($type2, $id); $test_Cuisine2->save(); $test_Cuisine->delete_cuisine(); $this->assertEquals([$test_Cuisine2], Cuisine::getAll()); }
function test_delete() { //Arrange $test_cuisine = new Cuisine("american", false, 4); $test_cuisine->save(); //Act $test_cuisine->delete(); $result = Cuisine::getAll(); //Assert $this->assertEquals([], $result); }
function test_deleteCuisine() { //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($id, $name, $phone, $price, $cuisine_id); $test_restaurant->save(); //Act $test_cuisine->delete(); //Assert $this->assertEquals([], Cuisine::getAll()); }
function testDelete() { //Arrange $name = "burgers"; $id = null; $test_cuisine = new Cuisine($name, $id); $test_cuisine->save(); $name2 = "sushi"; $test_cuisine2 = new Cuisine($name2, $id); $test_cuisine2->save(); //Act $test_cuisine->delete(); //Assert $this->assertEquals([$test_cuisine2], Cuisine::getAll()); }
function test_delete() { $name = "Chinese"; $id = null; $test_cuisine = new Cuisine($name, $id); $test_cuisine->save(); $name2 = "Greek"; $test_cuisine2 = new Cuisine($name2, $id); $test_cuisine2->save(); $test_cuisine->delete(); $this->assertEquals([$test_cuisine2], Cuisine::getAll()); }
function testDelete() { //Arrange $restaurant_name = "McDonalds"; $id = null; $test_restaurant = new Restaurant($restaurant_name, $id); $test_restaurant->save(); $restaurant_id = $test_restaurant->getId(); $cuisine_name = "burgers"; $test_cuisine = new Cuisine($cuisine_name, $id, $restaurant_id); $test_cuisine->save(); //Act $test_cuisine->deleteOne(); //Assert $this->assertEquals([], Cuisine::getAll()); }
?> </textarea> </div> <div class="form-group"> <label for="aerestaurantwebsite">Website</label> <input type="text" class="form-control" id="aerestaurantwebsite" maxlength="200" value="<?php echo $restaurantwebsite; ?> " name="website"> </div> <div class="form-group"> <label for="aerestaurantcuisine">Cuisine</label> <select class="form-control" id="aerestaurantcuisine" name="cuisineid"> <option></option> <?php $cuisines = Cuisine::getAll(); foreach ($cuisines as $cuisine) { echo ' <option value="' . $cuisine['id'] . '" ' . ($cuisine['id'] == $cuisineid ? 'selected' : '') . '>' . $cuisine['name'] . '</option>'; } ?> </select> </div> <div class="pull-right"> <?php if ($pageaction == "add") { $buttonvalue = 'addrestaurant'; $buttonlabel = 'Add Restaurant'; } else { $buttonvalue = 'editrestaurant'; $buttonlabel = 'Save Changes'; }