当前位置: 首页>>代码示例>>PHP>>正文


PHP Bar::addItem方法代码示例

本文整理汇总了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]);
 }
开发者ID:kellimargaret,项目名称:Beer-Me,代码行数:27,代码来源:BarTest.php

示例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);
 }
开发者ID:CaseyH33,项目名称:Beer_Me,代码行数:36,代码来源:PatronTest.php


注:本文中的Bar::addItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。