static function find($search_id) { $found_brewery = null; $all_breweries = Brewery::getAll(); foreach ($all_breweries as $brewery) { if ($brewery->getId() == $search_id) { $found_brewery = $brewery; } } return $found_brewery; }
$beer = Beer::find($id); $pub->deleteBeer($beer); return $app['twig']->render('pub_profile.html.twig', array('pub' => $pub, 'beers' => $pub->getBeers())); }); //User signup form $app->get('/signup', function () use($app) { $app['twig']->addGlobal('logged_user', $_SESSION['user']); return $app['twig']->render('drunk_signup.html.twig'); }); //User signup posting and returning to main page (no auto-login) $app->post('/signup', function () use($app) { $app['twig']->addGlobal('logged_user', $_SESSION['user']); $all_beers = Beer::getAll(); $new_drunk = new Drunk($_POST['name'], $_POST['date_of_birth'], $_POST['location'], $_POST['email'], $_POST['password']); $new_drunk->save(); return $app['twig']->render('index.html.twig', array('search_validate' => [], 'all_beers' => $all_beers, 'all_breweries' => Brewery::getAll(), 'all_pubs' => Pub::getAll())); }); //Get user profile $app->get('/public_login/{id}', function ($id) use($app) { $app['twig']->addGlobal('logged_user', $_SESSION['user']); $drunk = Drunk::find($id); $drunk_brews = $drunk->getBrews(); $brews = array(); foreach ($drunk_brews as $brew) { $beer = Beer::find($brew->getBeerId()); $beer_name = $beer->getName(); $pub = Pub::find($brew->getPubId()); $pub_name = $pub->getName(); $brew_info = array('beer_name' => $beer_name, 'pub_name' => $pub_name, 'beer_rating' => $brew->getBeerRating(), 'brew_date' => $brew->getBrewDate()); array_push($brews, $brew_info); }
<select name ='style_id' class='form-control'> <?php $styles = Style::getAll(); foreach ($styles as $style) { echo "<option value={$style->id}>{$style->name}</option>"; } ?> </select> </td> </tr> <tr> <th>Brewery:</th> <td> <select name='brewery_id' class='form-control'> <?php $breweries = Brewery::getAll(); foreach ($breweries as $brewery) { echo "<option value={$brewery->id}>{$brewery->name}</option>"; } ?> </select> </td> </tr> <tr> <th>Rating:</th> <td> <?php for ($i = 0; $i <= 4; $i++) { echo "<div class='radio-inline'>"; echo "<input type='radio' name='rating' value='" . ($i + 1) . "'>" . ($i + 1); echo "</div>";
function test_delete() { //Arrange $name = "Bullfrog Brewery"; $location = "Somewhere in Williamsport"; $link = "www.bullfrogbrewing.com"; $test_brewery = new Brewery($name, $location, $link); $test_brewery->save(); $name = "Yards Brewing Co."; $location = "Philthadone"; $link = "www.makebeer.com"; $test_brewery2 = new Brewery($name, $location, $link); $test_brewery2->save(); //Act $test_brewery->delete(); //Assert $result = Brewery::getAll(); $this->assertEquals([$test_brewery2], $result); }