mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
fix: serialize conditions to arrays before storage; type \$events
- serializeConditions() now maps CartCondition objects to arrays via
toArray() before passing to the driver, preventing json_encode()
producing {} for object values in the DatabaseDriver
- Add Dispatcher type hint to \$events property and constructor parameter
- Add database round-trip test for cart-level conditions
- Fix CartConditionsTest to retrieve condition objects from the cart
rather than relying on object-reference side-effects that no longer
hold after proper serialization
This commit is contained in:
@@ -950,8 +950,8 @@
|
||||
|
||||
expect($this->cart->getCalculatedValueForCondition('Coupon Discount'))->toEqual(200.0, 'Coupon Discount should be 200.0');
|
||||
expect($this->cart->getCalculatedValueForCondition('Gift Card'))->toEqual(0, 'Gift Card should be 0');
|
||||
expect($couponDiscount->getCalculatedValue())->toEqual(200.0, 'Coupon Discount value should be 200.0');
|
||||
expect($giftCard->getCalculatedValue())->toEqual(0, 'Gift Card value should be 0');
|
||||
expect($this->cart->getCondition('Coupon Discount')->getCalculatedValue(200.0))->toEqual(200.0, 'Coupon Discount value should be 200.0');
|
||||
expect($this->cart->getCondition('Gift Card')->getCalculatedValue(0))->toEqual(0, 'Gift Card value should be 0');
|
||||
});
|
||||
|
||||
test('calculate the subtotal correctly when one condition makes it $0, and the other adds $10', function () {
|
||||
|
||||
Reference in New Issue
Block a user