Example #1
0
 /**
  * @dataProvider dataForCreate
  */
 public function testPriceDiscount($productName, $quantity, $expectedPrice)
 {
     $item = new CartItem($this->factory->getProduct($productName), $quantity);
     $this->cart->addCartItem($item);
     $this->cashier->processNextCart($this->cart);
     $this->assertEquals(number_format($expectedPrice, 2), $this->cashier->getTotalPrice());
 }
Example #2
0
 /**
  * @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;
 }
Example #3
0
 public function processNextCart(Cart $cart)
 {
     $this->totalPrice = 0;
     $items = $cart->getItems();
     foreach ($items as $oneItem) {
         $discountedItem = $this->discountList->createDiscountedItem($oneItem);
         $this->totalPrice += $discountedItem->getPrice();
     }
 }