public function setUp() { $discountFactory = new DiscountFactory(); $discountList = new DiscountList(); $discountList->addDiscount($discountFactory->createPriceDiscountAboveQuantity('Apple', 5, 7)); $discountList->addDiscount($discountFactory->createQuantityDiscountAboveQuantity('Starship', 2, 1)); $this->cart = new Cart(); $this->cashier = new Cashier($discountList); $this->factory = new ProductFactory(); }
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()); }