コード例 #1
0
 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());
 }
コード例 #2
0
 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());
 }
コード例 #3
0
});
$app->get("/cuisines", function () use($app) {
    return $app['twig']->render('cuisines.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, 'restaraunts' => $cuisine->getRestaraunts()));
});
$app->post("/restaraunts", function () use($app) {
    $restaraunt_name = $_POST['RestarauntName'];
    $cuisine_id = $_POST['cuisine_id'];
    $address = $_POST['address'];
    $menu = $_POST['menu'];
    $hours = $_POST['hours'];
    $restaraunt = new Restaraunt($restaraunt_name, $id = null, $cuisine_id, $address, $menu, $hours);
    $restaraunt->save();
    $cuisine = Cuisine::find($cuisine_id);
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaraunts' => $cuisine->getRestaraunts()));
});
$app->post("/delete_restaraunts", function () use($app) {
    Restaraunt::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->post("/cuisines", function () use($app) {
    $cuisine = new Cuisine($_POST['CuisineName']);
    $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');