コード例 #1
0
ファイル: app.php プロジェクト: calascionec/tapThat
    }
    return $app['twig']->render("drunk_profile.html.twig", array('drunk' => $drunk, 'brews' => $brews));
});
//route that adds a brew to a profile page
$app->get('/add_brew', function () use($app) {
    $app['twig']->addGlobal('logged_user', $_SESSION['user']);
    $all_beers = Beer::getAll();
    $all_pubs = Pub::getAll();
    return $app['twig']->render("brew.html.twig", array('all_beers' => $all_beers, 'all_pubs' => $all_pubs));
});
//route posts a brew to a profile page
$app->post('/public_login/{id}', function ($id) use($app) {
    $app['twig']->addGlobal('logged_user', $_SESSION['user']);
    $new_brew = new Brew($_POST['beer_id'], $_POST['drunk_id'], $_POST['pub_id'], $_POST['rating'], $_POST['date']);
    $new_brew->save();
    $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);
    }
    return $app['twig']->render("drunk_profile.html.twig", array('drunk' => $drunk, 'brews' => $brews));
});
//Display all beers
$app->get('/beers', function () use($app) {
    $app['twig']->addGlobal('logged_user', $_SESSION['user']);
コード例 #2
0
ファイル: DrunkTest.php プロジェクト: calascionec/tapThat
 function testFind()
 {
     //Arrange
     $name = "Person 1";
     $date_of_birth = "1988-03-04";
     $location = "Portland, OR";
     $email = "*****@*****.**";
     $password = "******";
     $test_drunk = new Drunk($name, $date_of_birth, $location, $email, $password);
     $test_drunk->save();
     $name2 = "Person 1";
     $date_of_birth2 = "1988-03-04";
     $location2 = "Portland, OR";
     $email2 = "*****@*****.**";
     $password2 = "them";
     $test_drunk2 = new Drunk($name2, $date_of_birth2, $location2, $email2, $password2);
     $test_drunk2->save();
     //Act
     $result = Drunk::find($test_drunk2->getId());
     //Assert
     $this->assertEquals($test_drunk2, $result);
 }