test: add withCoupon test and fix withItems ID collision

This commit is contained in:
Joel Male
2026-05-27 21:33:35 +10:00
parent 61863e0bd5
commit 8d04d18b48
2 changed files with 16 additions and 1 deletions
+14
View File
@@ -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();
});
});