/** * @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()); }
/** * @param CartItem[] $appleItems * * @depends testAddProduct */ public function testGetItemNormalPrice($appleItems) { $apple = $this->productFactory->getProduct('Apple'); $oneApplePrice = $apple->getPrice(); $totalPrice = $oneApplePrice * $appleItems[0]->getQuantity(); $this->assertEquals($totalPrice, $appleItems[0]->getPrice()); }
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()); }
/** * @dataProvider dataForCreate */ public function testGetUnit($productName, $quantity, $unit) { $product = $this->factory->getProduct($productName); $item = new CartItem($product, $quantity); $this->assertEquals($unit, $item->getUnit()); }
/** * @expectedException InvalidArgumentException */ public function testThrowException() { $this->factory->getProduct('NonExistentProduct'); }