mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
test: add withCoupon test and fix withItems ID collision
This commit is contained in:
@@ -57,4 +57,18 @@ function makeCartForFactory(): Cart
|
||||
|
||||
expect(array_unique($ids))->toHaveCount(3);
|
||||
});
|
||||
|
||||
test('withCoupon adds a coupon condition to the cart', function () {
|
||||
$coupon = new class extends \Wearepixel\Cart\Coupons\Coupon {
|
||||
protected string $code = 'SAVE10';
|
||||
protected string $value = '-10%';
|
||||
protected string $target = 'subtotal';
|
||||
|
||||
public function isValid(): bool { return true; }
|
||||
};
|
||||
|
||||
$this->factory->withCoupon($coupon);
|
||||
|
||||
expect($this->cart->getCondition('SAVE10'))->not->toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user