/** * Remove coupon in the cart * * @expectedException App\Librairies\Shoppingcart\Exceptions\CouponNotFoundException */ public function testRemoveItem() { Cart::addCoupon('TEST20', 5.5); $this->assertEquals(1, count(Cart::coupons()->all())); Cart::removeCoupon('TEST20'); $this->assertEquals(0, count(Cart::coupons()->all())); Cart::removeCoupon('UNKNOWN_COUPON'); }
/** * Removes a coupon from the list * * @param string $couponName * @return Response */ public function remove($couponName) { try { Cart::removeCoupon(strtolower($couponName)); } catch (Exceptions\CouponNotFoundException $e) { // Do nothing } return redirect()->route('cart.index'); }