diff --git a/tests/core/Unit/DiscountTypes/BuyXGetYTest.php b/tests/core/Unit/DiscountTypes/BuyXGetYTest.php index 851b48c7aa..0fe1dd206c 100644 --- a/tests/core/Unit/DiscountTypes/BuyXGetYTest.php +++ b/tests/core/Unit/DiscountTypes/BuyXGetYTest.php @@ -377,7 +377,7 @@ ], ]); - Discount::factory()->create([ + $discountB = Discount::factory()->create([ 'type' => AmountOff::class, 'name' => 'Test A amount off', 'uses' => 0, @@ -394,6 +394,13 @@ ], ]); + $discountB->customerGroups()->sync([ + $customerGroup->id => [ + 'enabled' => false, + 'starts_at' => now(), + ], + ]); + $discount->customerGroups()->sync([ $customerGroup->id => [ 'enabled' => true, @@ -421,8 +428,11 @@ $cart = $cart->calculate(); - expect($cart->total->value)->toEqual(1200); - expect($cart->freeItems)->toHaveCount(1); + expect($cart->discountTotal->value)->toBe(1010) + ->and($cart->subTotalDiscounted->value)->toBe(2000 - 1010) + ->and($cart->subTotal->value)->toBe(2000) + ->and($cart->total->value)->toBe(1188) + ->and($cart->freeItems)->toHaveCount(1); }); test('can apply multiple different discounts', function () { diff --git a/tests/core/Unit/Managers/DiscountManagerTest.php b/tests/core/Unit/Managers/DiscountManagerTest.php index 85732f6b41..5e98b35617 100644 --- a/tests/core/Unit/Managers/DiscountManagerTest.php +++ b/tests/core/Unit/Managers/DiscountManagerTest.php @@ -85,6 +85,24 @@ $discount = Discount::factory()->create(); + $discount->customerGroups()->sync([ + $customerGroup->id => [ + 'enabled' => false, + 'starts_at' => null, + ], + ]); + + $discount->channels()->sync([ + $channel->id => [ + 'enabled' => false, + 'starts_at' => null, + ], + $channelTwo->id => [ + 'enabled' => false, + 'starts_at' => null, + ], + ]); + $manager = app(DiscountManagerInterface::class); expect($manager->getDiscounts())->toBeEmpty();