當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。