コード例 #1
0
ファイル: CartTest.php プロジェクト: mwnn/kata-base-php
 /**
  * @param $cart
  *
  * @depends testEmpty
  */
 public function testAddProduct(Cart $cart)
 {
     $cart->addCartItem(new CartItem($this->productFactory->getProduct('Apple'), 3));
     $appleItems = $cart->getItems();
     $this->assertInstanceOf('Kata\\H03Supermarket\\Concrete\\CartItem', $appleItems[0]);
     return $appleItems;
 }
コード例 #2
0
ファイル: Cashier.php プロジェクト: mwnn/kata-base-php
 public function processNextCart(Cart $cart)
 {
     $this->totalPrice = 0;
     $items = $cart->getItems();
     foreach ($items as $oneItem) {
         $discountedItem = $this->discountList->createDiscountedItem($oneItem);
         $this->totalPrice += $discountedItem->getPrice();
     }
 }