function test_find()
 {
     //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
     $result = Restaraunt::find($test_restaraunt->getId());
     //Assert
     $this->assertEquals($test_restaraunt, $result);
 }
예제 #2
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;