/** * @dataProvider testApplicableProvider * @group coupon */ public function testApplicable($period, $products, $applied) { $term = new Term($period); $term->setPrice(12.0); $product = new \Cart\Catalog\Product(); $product->setId(24); $product->getBilling()->addTerm($term); $catalog = new Catalog(); $item = $catalog->getCartItem($product); $cart = $this->getCart(); $cart->add($item); $total = $cart->total(); $coupon = new Coupon('COUPON'); $coupon->setProducts($products); $coupon->setType('PercentDiscount'); $coupon->setConfig(['percent' => 50]); $coupon->calculateDiscount($cart); $this->assertEquals($total != $cart->total(), $applied); }
/** * @param Coupon $coupon */ public function setCoupon(Coupon $coupon) { $this->coupon = $coupon; $coupon->calculateDiscount($this->cart); }