From ddb82720184a0d02d3788cf5fe33d1b9ffed178f Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Tue, 21 Nov 2017 15:45:33 -0500 Subject: [PATCH 1/2] Adding larger test --- build/logs/clover.xml | 596 +++++++++++++++++++++--------------------- tests/TotalsTest.php | 38 +++ 2 files changed, 336 insertions(+), 298 deletions(-) diff --git a/build/logs/clover.xml b/build/logs/clover.xml index 207e19b..136798b 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,21 +1,21 @@ - - + + - + - - - - - - - + + + + + + + - + @@ -32,39 +32,39 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -83,50 +83,50 @@ - - - - - + + + + + - - - - - - - - - + + + + + + + + + - - - - + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + - + - + @@ -154,7 +154,7 @@ - + @@ -181,36 +181,36 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - + + + @@ -219,23 +219,23 @@ - - - + + + - - - - + + + + - - + + @@ -251,23 +251,23 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + + @@ -293,14 +293,14 @@ - - - - - - - - + + + + + + + + @@ -331,24 +331,24 @@ - - - - - - - - + + + + + + + + - - - - - + + + + + @@ -363,72 +363,72 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + @@ -448,79 +448,79 @@ - - - + + + - - + + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - + + + + + + + + + - + - + @@ -529,52 +529,52 @@ - + - - - - - - - - - - - + + + + + + + + + + + - + - + - + - + - + @@ -582,7 +582,7 @@ - + @@ -594,49 +594,49 @@ - + - - - - - - - + + + + + + + - - - + + + - - - + + + - - - + + + - - - - - - - + + + + + + + - + - + - - + + - + @@ -677,8 +677,8 @@ - - + + diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index 64b7bbb..d0b8509 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -265,4 +265,42 @@ public function testDoubleDiscounts() $this->assertEquals(19.95, $this->laracart->taxTotal(false)); $this->assertEquals(114.95, $this->laracart->total(false)); } + + public function testTaxationOnCoupons() { + // Add to cart + $this->laracart->add( + 1, + 'test', + 52, + 107.44, + [ + 'tax' => 0.21, + ] + ); + + $this->assertEquals(5586.88, $this->laracart->subTotal(false)); + $this->assertEquals(0, $this->laracart->totalDiscount(false)); + $this->assertEquals(1173.24, $this->laracart->taxTotal(false)); + $this->assertEquals(6760.12, $this->laracart->total(false)); + + // Test discount % + $coupon = new LukePOLO\LaraCart\Coupons\Percentage('7,5%', 0.075); + $this->laracart->addCoupon($coupon); + + $this->assertEquals(5586.88, $this->laracart->subTotal(false)); + $this->assertEquals(419.02, $this->laracart->totalDiscount(false)); + $this->assertEquals(1085.25, $this->laracart->taxTotal(false)); + $this->assertEquals(6253.11, $this->laracart->total(false)); + + $this->laracart->removeCoupons(); + + // Test discount fixed + $coupon = new LukePOLO\LaraCart\Coupons\Fixed('100 euro', 100); + $this->laracart->addCoupon($coupon); + + $this->assertEquals(5586.88, $this->laracart->subTotal(false)); + $this->assertEquals(100, $this->laracart->totalDiscount(false)); + $this->assertEquals(1152.24, $this->laracart->taxTotal(false)); + $this->assertEquals(6639.12, $this->laracart->total(false)); + } } From a1ad83264aeb7e38ee7945695782cf71eaa9656a Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Tue, 21 Nov 2017 20:45:40 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI [ci skip] [skip ci] --- tests/TotalsTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index d0b8509..23a3291 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -266,7 +266,8 @@ public function testDoubleDiscounts() $this->assertEquals(114.95, $this->laracart->total(false)); } - public function testTaxationOnCoupons() { + public function testTaxationOnCoupons() + { // Add to cart $this->laracart->add( 1,