本文整理汇总了PHP中Bar::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Bar::addItem方法的具体用法?PHP Bar::addItem怎么用?PHP Bar::addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bar
的用法示例。
在下文中一共展示了Bar::addItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAllTokens
function testGetAllTokens()
{
$name = "Side Street";
$phone = "555-555-5555";
$address = "123 ABC. Street";
$website = "http://www.sidestreetpdx.com";
$test_bar = new Bar($name, $phone, $address, $website);
$test_bar->save();
$test_item = new Item("tacos", 2.25);
$test_item->save();
$test_bar->addItem($test_item);
$returned_ids = $GLOBALS['DB']->query("SELECT id FROM menus WHERE bar_id = {$test_bar->getId()};");
$ids = array();
foreach ($returned_ids as $returned_id) {
$id = $returned_id['id'];
array_push($ids, $id);
}
$name = "Kyle Pratuch";
$email = "kyle.pratuch@gmail.com";
$test_patron = new Patron($name, $email);
$test_patron->save();
$test_token = new Token($test_patron->getId(), $ids[0], 3);
$test_token->save();
// var_dump($test_token);
$result = $test_bar->getAllTokens();
$this->assertEquals($test_token, $result[0]);
}
示例2: testGetTokens
function testGetTokens()
{
//Arrange
$name = "Kyle Pratuch";
$email = "kyle.pratuch@gmail.com";
$test_recipient = new Patron($name, $email);
$test_recipient->save();
$name2 = "Jason Bethel";
$email2 = "jlbethel@gmail.com";
$test_sender = new Patron($name2, $email2);
$test_sender->save();
$bar_name = "Side Street";
$phone = "555-555-5555";
$address = "123 ABC. Street";
$website = "http://www.sidestreetpdx.com";
$test_bar = new Bar($bar_name, $phone, $address, $website);
$test_bar->save();
$description = "Pliny the Elder";
$cost = 5.0;
$id = null;
$test_item = new Item($description, $cost, $id);
$test_item->save();
$test_bar->addItem($test_item);
$patron_id = $test_recipient->getId();
$sender_id = $test_sender->getId();
$menu_id = 1;
$test_token = new Token($patron_id, $menu_id, $sender_id);
$test_token->save();
$menu_id2 = 2;
$test_token2 = new Token($patron_id, $menu_id2, $sender_id);
$test_token2->save();
//Act
$result = $test_recipient->getTokens();
//Assert
$this->assertEquals([$test_token, $test_token2], $result);
}