Beispiel #1
0
 private function getQuantityDiscountAboveQuantity(CartItem $item)
 {
     $quantity = $item->getQuantity();
     $discountQuantity = $this->benefit * (int) ($quantity / ($this->minPriceOrQuantity + $this->benefit));
     $quantityToPay = $this->minPriceOrQuantity < $quantity ? $quantity - $discountQuantity : $quantity;
     return $quantityToPay;
 }
 public function testGetDiscountedItemPrice()
 {
     $productName = 'Apple';
     $item = new CartItem($this->productFactory->getProduct($productName), 10);
     $itemDefaultPrice = $item->getPrice();
     $priceDiscount = $this->discountFactory->createPriceDiscountAboveQuantity($productName, 5, 7);
     $this->list->addDiscount($priceDiscount);
     /**
      * @var CartItem
      */
     $discountedItem = $this->list->createDiscountedItem($item);
     $this->assertNotEquals($itemDefaultPrice, $discountedItem->getPrice());
 }
Beispiel #3
0
 /**
  * @dataProvider dataForCreate
  */
 public function testGetUnit($productName, $quantity, $unit)
 {
     $product = $this->factory->getProduct($productName);
     $item = new CartItem($product, $quantity);
     $this->assertEquals($unit, $item->getUnit());
 }