Exemplo n.º 1
0
 function test_deleteAllBeers()
 {
     //Arrange
     $name = "Paddys";
     $location = "462 Over There Way";
     $link = "www.paddyspub.com";
     $test_pub = new Pub($name, $location, $link);
     $test_pub->save();
     $id = null;
     $name = "Lip Blaster";
     $type = "IPA";
     $abv = 4.2;
     $ibu = 10;
     $region = "Pacific Northwest";
     $brewery_id = 1;
     $test_beer = new Beer($id, $name, $type, $abv, $ibu, $region, $brewery_id);
     $test_beer->save();
     $id = null;
     $name = "Hip Hops";
     $type = "Pale Ale";
     $abv = 3.2;
     $ibu = 4;
     $region = "South Central LA";
     $brewery_id = 2;
     $test_beer2 = new Beer($id, $name, $type, $abv, $ibu, $region, $brewery_id);
     $test_beer2->save();
     $test_pub->addBeer($test_beer);
     $test_pub->addBeer($test_beer2);
     //Act
     $test_pub->deleteAllBeers();
     //Assert
     $result = $test_pub->getBeers();
     $this->assertEquals([], $result);
 }
Exemplo n.º 2
0
    return $app['twig']->render('beer.html.twig', array('beer' => $beer, 'pubs' => $pubs_on_tap, 'brewery' => $brewery));
});
//takes pub user to a page where they can add a pub
$app->get('/pub_login', function () use($app) {
    $app['twig']->addGlobal('logged_user', $_SESSION['user']);
    $all_pubs = Pub::getAll();
    return $app['twig']->render('pub.html.twig', array('pubs' => $all_pubs));
});
//posts the new pub to the pubs homepage
$app->post('/pub_login', function () use($app) {
    $app['twig']->addGlobal('logged_user', $_SESSION['user']);
    $name = $_POST['name'];
    $location = $_POST['location'];
    $link = $_POST['link'];
    $new_pub = new Pub($name, $location, $link);
    $new_pub->save();
    return $app['twig']->render('pub.html.twig', array('pubs' => Pub::getAll()));
});
//deletes all the pubs
$app->delete('/pub_login', function () use($app) {
    $app['twig']->addGlobal('logged_user', $_SESSION['user']);
    Pub::deleteAll();
    return $app['twig']->render('pub.html.twig', array('all_pubs' => Pub::getAll()));
});
//takes user to an individual's pub page
$app->get('/pub/{id}', function ($id) use($app) {
    $app['twig']->addGlobal('logged_user', $_SESSION['user']);
    $pub = Pub::find($id);
    return $app['twig']->render('pub_profile.html.twig', array('pub' => $pub, 'beers' => $pub->getBeers()));
});
//allows user to add a particular beer to a particular pub
Exemplo n.º 3
0
 function testGetPubs()
 {
     //Arrange
     $id = null;
     $name = "Lip Blaster";
     $type = "IPA";
     $abv = 4.2;
     $ibu = 10;
     $region = "Pacific Northwest";
     $brewery_id = 1;
     $test_beer = new Beer($id, $name, $type, $abv, $ibu, $region, $brewery_id);
     $test_beer->save();
     $name = "The Outback Steakhouse";
     $location = "300NW Outback Steak Rd";
     $link = "http://www.outback.com/";
     $test_pub = new Pub($name, $location, $link);
     $test_pub->save();
     $test_pub->addBeer($test_beer);
     //Act
     $result = $test_beer->getPubs();
     //Assert
     $this->assertEquals([$test_pub], $result);
 }