From 03e4782215e49fee4fbfec5db86a66ab1371fcd9 Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Mon, 16 Oct 2017 07:06:12 -0400 Subject: [PATCH 1/7] fixed test --- build/logs/clover.xml | 4 ++-- tests/CouponsTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/logs/clover.xml b/build/logs/clover.xml index a9e6ac9..57ba1b6 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,6 +1,6 @@ - - + + diff --git a/tests/CouponsTest.php b/tests/CouponsTest.php index 98dc752..e4c064f 100644 --- a/tests/CouponsTest.php +++ b/tests/CouponsTest.php @@ -261,7 +261,7 @@ public function testCouponsNotTaxableItem() $this->assertEquals('20%', $percentCoupon->displayValue()); $this->assertEquals('0.20', $percentCoupon->discount()); - $this->app['config']->set('laracart.discountTaxable', false); + $this->app['config']->set('laracart.discountTaxable', true); $this->assertEquals(0, $this->laracart->taxTotal(false)); @@ -284,11 +284,11 @@ public function testCouponsTaxableItem() $this->assertEquals('20%', $percentCoupon->displayValue()); $this->assertEquals('0.20', $percentCoupon->discount()); - $this->app['config']->set('laracart.discountTaxable', false); + $this->app['config']->set('laracart.discountTaxable', true); - $this->assertEquals('0.06', $this->laracart->taxTotal(false)); + $this->assertEquals('0.07', $this->laracart->taxTotal(false)); - $this->assertEquals('0.86', $this->laracart->total(false)); + $this->assertEquals('0.87', $this->laracart->total(false)); } /** From 3a47878e68c1cb60e64b7156adc75de600ec24a9 Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Mon, 16 Oct 2017 07:11:22 -0400 Subject: [PATCH 2/7] remove deprecation --- build/logs/clover.xml | 1162 ++++++++++++++++++------------------ src/Traits/CouponTrait.php | 18 - src/config/laracart.php | 11 - tests/TotalsTest.php | 24 + 4 files changed, 617 insertions(+), 598 deletions(-) diff --git a/build/logs/clover.xml b/build/logs/clover.xml index 57ba1b6..618a135 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,498 +1,514 @@ - - + + - - - - - - - + + + + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -505,47 +521,55 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -595,87 +619,87 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -685,6 +709,6 @@ - + diff --git a/src/Traits/CouponTrait.php b/src/Traits/CouponTrait.php index fd0f117..410687f 100644 --- a/src/Traits/CouponTrait.php +++ b/src/Traits/CouponTrait.php @@ -48,24 +48,6 @@ public function canApply() } } - /** - * Get the reason why a coupon has failed to apply. - * - * @deprecated 1.3 - * - * @return string - */ - public function getMessage() - { - try { - $this->discount(true); - - return config('laracart.coupon_applied_message', 'Coupon Applied'); - } catch (CouponException $e) { - return $e->getMessage(); - } - } - /** * Gets the failed message for a coupon. * diff --git a/src/config/laracart.php b/src/config/laracart.php index 7ba8fe9..251b965 100644 --- a/src/config/laracart.php +++ b/src/config/laracart.php @@ -85,17 +85,6 @@ */ 'multiple_coupons' => false, - /* - | - | **** DEPRECATED IN 1.3 **** - | - |-------------------------------------------------------------------------- - | Applied message when using getMessage on a coupon - |-------------------------------------------------------------------------- - | - */ - 'coupon_applied_message' => 'Coupon Applied', - /* |-------------------------------------------------------------------------- | The default item model for your relations diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index 1b4ed60..a3cf434 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -242,4 +242,28 @@ public function testTaxTotalWithDiscounts() $this->laracart->addCoupon($coupon); } + + public function testDoubleDiscounts() + { + $this->laracart->add(1, 'Test Product', 1, 100, ['tax' => 0.21]); + + $coupon = new LukePOLO\LaraCart\Coupons\Percentage('test', 0.05, [ + 'name' => '5% off', + 'description' => '5% off test', + ]); + + $this->laracart->addCoupon($coupon); + +// $cart->subTotal(false) => 100 +// $cart->totalDiscount(false) => 5 +// +// $cart->taxTotal(false) => 16.00 +// $cart->total(false) => 111.00 + + + dump($this->laracart->subTotal(false)); + dump($this->laracart->totalDiscount(false)); + dump($this->laracart->taxTotal(false)); + dump($this->laracart->total(false)); + } } From 29d316a15b2a83d17018fced81ff9da3db677fae Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Mon, 16 Oct 2017 11:11:31 +0000 Subject: [PATCH 3/7] Apply fixes from StyleCI [ci skip] [skip ci] --- tests/TotalsTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index a3cf434..c3a5c27 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -260,7 +260,6 @@ public function testDoubleDiscounts() // $cart->taxTotal(false) => 16.00 // $cart->total(false) => 111.00 - dump($this->laracart->subTotal(false)); dump($this->laracart->totalDiscount(false)); dump($this->laracart->taxTotal(false)); From 7c1fdd09b155f90fadde1ccbd8dfdbccd3194da3 Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Mon, 16 Oct 2017 08:07:18 -0400 Subject: [PATCH 4/7] a work in progress --- build/logs/clover.xml | 1175 ++++++++++++++++++------------------ src/CartItem.php | 2 +- src/LaraCart.php | 10 +- src/Traits/CouponTrait.php | 26 +- tests/CouponsTest.php | 18 +- tests/TotalsTest.php | 10 +- 6 files changed, 621 insertions(+), 620 deletions(-) diff --git a/build/logs/clover.xml b/build/logs/clover.xml index 618a135..1781ddd 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,514 +1,498 @@ - - + + - - - - - - - + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -521,55 +505,47 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -619,96 +595,97 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + - + - - - - - - - + + + + + + - + diff --git a/src/CartItem.php b/src/CartItem.php index 8a7e52d..a28ff5c 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -298,7 +298,7 @@ public function tax($amountNotTaxable = 0) return $totalTax - $amountNotTaxable; } - return $this->tax * ($this->subTotal(false, config('laracart.discountTaxable', true), true) - $amountNotTaxable); + return $this->tax * ($this->subTotal(false, !config('laracart.discountTaxable', false), true) - $amountNotTaxable); } /** diff --git a/src/LaraCart.php b/src/LaraCart.php index a36962d..e49e08f 100644 --- a/src/LaraCart.php +++ b/src/LaraCart.php @@ -569,13 +569,17 @@ public function taxTotal($format = true, $withFees = true) $totalDiscount = $this->totalDiscount(false, false); if ($this->count() != 0) { + /** + * @var $index + * @var CartItem $item + */ foreach ($this->getItems() as $index => $item) { if ($discounted >= $totalDiscount) { - $totalTax += $item->tax(); + $totalTax += $item->tax(config('laracart.discountTaxable', false) === false ? $item->getDiscount(false) : 0); } else { - $itemPrice = $item->subTotal(false); + $itemPrice = $item->subTotal(false, config('laracart.discountTaxable', false)); if (($discounted + $itemPrice) > $totalDiscount) { - $totalTax += config('laracart.discountTaxable', true) ? $item->tax() : $item->tax($totalDiscount - $discounted); + $totalTax += config('laracart.discountTaxable', false) ? $item->tax() : $item->tax($totalDiscount - $discounted); } $discounted += $itemPrice; diff --git a/src/Traits/CouponTrait.php b/src/Traits/CouponTrait.php index 410687f..eba2a56 100644 --- a/src/Traits/CouponTrait.php +++ b/src/Traits/CouponTrait.php @@ -48,6 +48,24 @@ public function canApply() } } + /** + * Get the reason why a coupon has failed to apply. + * + * @deprecated 1.3 + * + * @return string + */ + public function getMessage() + { + try { + $this->discount(true); + + return config('laracart.coupon_applied_message', 'Coupon Applied'); + } catch (CouponException $e) { + return $e->getMessage(); + } + } + /** * Gets the failed message for a coupon. * @@ -139,14 +157,18 @@ public function checkValidTimes(Carbon $startDate, Carbon $endDate, $throwErrors * Sets a discount to an item with what code was used and the discount amount. * * @param CartItem $item + * @param $discountAmount * * @throws InvalidPrice */ - public function setDiscountOnItem(CartItem $item) + public function setDiscountOnItem(CartItem $item, $discountAmount) { + if (!is_numeric($discountAmount)) { + throw new InvalidPrice('You must use a discount amount.'); + } $this->appliedToCart = false; $item->code = $this->code; - $item->discount = $this->discount(); + $item->discount = $discountAmount; $item->couponInfo = $this->options; } } diff --git a/tests/CouponsTest.php b/tests/CouponsTest.php index e4c064f..0f8b7a6 100644 --- a/tests/CouponsTest.php +++ b/tests/CouponsTest.php @@ -191,7 +191,7 @@ public function testCheckValidTimes() */ public function testSetDiscountOnItem() { - $item = $this->addItem(2, 30); + $item = $this->addItem(1, 100); $fixedCoupon = new LukePOLO\LaraCart\Coupons\Fixed('10OFF', 10); @@ -199,25 +199,29 @@ public function testSetDiscountOnItem() $coupon = $this->laracart->findCoupon('10OFF'); - $this->assertEquals('53.50', $this->laracart->total(false)); + $this->assertEquals(90 * 1.07, $this->laracart->total(false)); $coupon->setDiscountOnItem($item, 10.00); $this->assertEquals('10OFF', $item->code); - $item = $this->addItem(); +// dd($this->laracart->total(false)); + + $this->assertEquals(round(90 * 1.07), $this->laracart->total(false)); +// dd('fixed'); + $this->app['config']->set('laracart.discountTaxable', true); - $this->assertEquals('54.57', $this->laracart->total(false)); + $this->assertEquals(round(90 + (100 * .07)), $this->laracart->total(false)); $this->app['config']->set('laracart.discountTaxable', false); - $this->assertEquals('55.27', $this->laracart->total(false)); + $this->assertEquals(round(90 * 1.07), $this->laracart->total(false)); $this->laracart->removeCoupon('10OFF'); - $this->assertEquals('65.27', $this->laracart->total(false)); + $this->assertEquals(107, $this->laracart->total(false)); $this->assertNull($item->code); $this->assertEquals(0, $item->discount); @@ -237,7 +241,7 @@ public function testDiscountTotals() $coupon = $this->laracart->findCoupon('10OFF'); - $coupon->setDiscountOnItem($item); + $coupon->setDiscountOnItem($item, 10.00); $this->assertEquals('10OFF', $item->code); diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index a3cf434..7ceba59 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -245,7 +245,7 @@ public function testTaxTotalWithDiscounts() public function testDoubleDiscounts() { - $this->laracart->add(1, 'Test Product', 1, 100, ['tax' => 0.21]); + $item = $this->laracart->add(1, 'Test Product', 1, 100, ['tax' => 0.21]); $coupon = new LukePOLO\LaraCart\Coupons\Percentage('test', 0.05, [ 'name' => '5% off', @@ -253,13 +253,7 @@ public function testDoubleDiscounts() ]); $this->laracart->addCoupon($coupon); - -// $cart->subTotal(false) => 100 -// $cart->totalDiscount(false) => 5 -// -// $cart->taxTotal(false) => 16.00 -// $cart->total(false) => 111.00 - + $coupon->setDiscountOnItem($item, $item->price(false) * $coupon->value); dump($this->laracart->subTotal(false)); dump($this->laracart->totalDiscount(false)); From 4dd2dc778457bdb829246fc23216fd6ee74332f9 Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Mon, 16 Oct 2017 12:07:46 +0000 Subject: [PATCH 5/7] Apply fixes from StyleCI [ci skip] [skip ci] --- src/LaraCart.php | 2 +- tests/CouponsTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LaraCart.php b/src/LaraCart.php index e49e08f..b4d9286 100644 --- a/src/LaraCart.php +++ b/src/LaraCart.php @@ -570,7 +570,7 @@ public function taxTotal($format = true, $withFees = true) if ($this->count() != 0) { /** - * @var $index + * @var * @var CartItem $item */ foreach ($this->getItems() as $index => $item) { diff --git a/tests/CouponsTest.php b/tests/CouponsTest.php index 0f8b7a6..26b5858 100644 --- a/tests/CouponsTest.php +++ b/tests/CouponsTest.php @@ -210,7 +210,7 @@ public function testSetDiscountOnItem() $this->assertEquals(round(90 * 1.07), $this->laracart->total(false)); // dd('fixed'); - + $this->app['config']->set('laracart.discountTaxable', true); $this->assertEquals(round(90 + (100 * .07)), $this->laracart->total(false)); From 83284428f92140c700430e65182815884b06ce7d Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Tue, 17 Oct 2017 09:34:16 -0400 Subject: [PATCH 6/7] we got all tests to pass and should be good now --- build/logs/clover.xml | 1184 +++++++++++++++++++++-------------------- src/LaraCart.php | 2 +- tests/CouponsTest.php | 10 +- 3 files changed, 607 insertions(+), 589 deletions(-) diff --git a/build/logs/clover.xml b/build/logs/clover.xml index 1781ddd..b041ab2 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,579 +1,601 @@ - - + + - + - - - - - - - + + + + + + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - + + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + @@ -581,7 +603,7 @@ - + @@ -593,91 +615,91 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - + + @@ -686,6 +708,6 @@ - + diff --git a/src/LaraCart.php b/src/LaraCart.php index b4d9286..2f0b1ac 100644 --- a/src/LaraCart.php +++ b/src/LaraCart.php @@ -575,7 +575,7 @@ public function taxTotal($format = true, $withFees = true) */ foreach ($this->getItems() as $index => $item) { if ($discounted >= $totalDiscount) { - $totalTax += $item->tax(config('laracart.discountTaxable', false) === false ? $item->getDiscount(false) : 0); + $totalTax += $item->tax(); } else { $itemPrice = $item->subTotal(false, config('laracart.discountTaxable', false)); if (($discounted + $itemPrice) > $totalDiscount) { diff --git a/tests/CouponsTest.php b/tests/CouponsTest.php index 26b5858..7c85620 100644 --- a/tests/CouponsTest.php +++ b/tests/CouponsTest.php @@ -205,19 +205,15 @@ public function testSetDiscountOnItem() $this->assertEquals('10OFF', $item->code); -// dd($this->laracart->total(false)); - - $this->assertEquals(round(90 * 1.07), $this->laracart->total(false)); - -// dd('fixed'); + $this->assertEquals(90 * 1.07, $this->laracart->total(false)); $this->app['config']->set('laracart.discountTaxable', true); - $this->assertEquals(round(90 + (100 * .07)), $this->laracart->total(false)); + $this->assertEquals(90 + (100 * .07), $this->laracart->total(false)); $this->app['config']->set('laracart.discountTaxable', false); - $this->assertEquals(round(90 * 1.07), $this->laracart->total(false)); + $this->assertEquals(90 * 1.07, $this->laracart->total(false)); $this->laracart->removeCoupon('10OFF'); From ca91ca004e5e66cc414a9be284f59e918c17f55e Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Tue, 17 Oct 2017 09:36:04 -0400 Subject: [PATCH 7/7] testing double discounts --- build/logs/clover.xml | 120 +++++++++++++++++++++--------------------- tests/TotalsTest.php | 8 +-- 2 files changed, 65 insertions(+), 63 deletions(-) diff --git a/build/logs/clover.xml b/build/logs/clover.xml index b041ab2..1247696 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,6 +1,6 @@ - - + + @@ -199,7 +199,7 @@ - + @@ -354,11 +354,11 @@ - - - - - + + + + + @@ -378,7 +378,7 @@ - + @@ -386,9 +386,9 @@ - - - + + + @@ -435,11 +435,11 @@ - + - - + + @@ -463,14 +463,14 @@ - - - - - - - - + + + + + + + + @@ -521,53 +521,55 @@ - + - - - - - - - - - + + + + + + + + + + + - + + - + + + + - + + + - + - - - - - - + + + + + - - - - - - + @@ -617,7 +619,7 @@ - + @@ -644,19 +646,19 @@ - - - + + + - + - + - + - + @@ -695,7 +697,7 @@ - + @@ -708,6 +710,6 @@ - + diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index 7ceba59..8cdd9ef 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -255,9 +255,9 @@ public function testDoubleDiscounts() $this->laracart->addCoupon($coupon); $coupon->setDiscountOnItem($item, $item->price(false) * $coupon->value); - dump($this->laracart->subTotal(false)); - dump($this->laracart->totalDiscount(false)); - dump($this->laracart->taxTotal(false)); - dump($this->laracart->total(false)); + $this->assertEquals(95, $this->laracart->subTotal(false)); + $this->assertEquals(5, $this->laracart->totalDiscount(false)); + $this->assertEquals(19.95, $this->laracart->taxTotal(false)); + $this->assertEquals(114.95, $this->laracart->total(false)); } }