function test_RestarauntDelete()
 {
     //Arrange
     $cuisine_name = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($cuisine_name, $id);
     $test_cuisine->save();
     $restaraunt_name = "Mamas Home Country Cookin";
     $cuisine_id = $test_cuisine->getId();
     $test_restaraunt = new Restaraunt($restaraunt_name, $id, $cuisine_id);
     $test_restaraunt->save();
     $restaraunt_name2 = "Big Bobs Fried Alligator";
     $test_restaraunt2 = new Restaraunt($restaraunt_name2, $id, $cuisine_id);
     $test_restaraunt2->save();
     //Act
     $test_restaraunt->delete();
     //Assert
     $this->assertEquals([$test_restaraunt2], Restaraunt::getAll());
 }
예제 #2
0
 static function find($search_id)
 {
     $found_restaraunt = null;
     $restaraunts = Restaraunt::getAll();
     foreach ($restaraunts as $restaraunt) {
         $restaraunt_id = $restaraunt->getId();
         if ($restaraunt_id == $search_id) {
             $found_restaraunt = $restaraunt;
         }
     }
     return $found_restaraunt;
 }
 function testDeleteCuisineRestaraunts()
 {
     //Arrange
     $cuisine_name = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($cuisine_name, $id);
     $test_cuisine->save();
     $restaraunt_name = "Big Bubba/'s Tuscan Pizza";
     $cuisine_id = $test_cuisine->getId();
     $test_restaraunt = new Restaraunt($restaraunt_name, $id, $cuisine_id);
     $test_restaraunt->save();
     //Act
     $test_cuisine->delete();
     //Assert
     $this->assertEquals([], Restaraunt::getAll());
 }
예제 #4
0
    $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;