mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
fix: guard null writes in SessionDriver::setSessionKey
This commit is contained in:
@@ -70,4 +70,15 @@
|
||||
test('getSessionModel returns null', function () {
|
||||
expect($this->driver->getSessionModel())->toBeNull();
|
||||
});
|
||||
|
||||
test('setSessionKey on empty cart does not write null to session', function () {
|
||||
$this->driver->setSessionKey('new-key');
|
||||
|
||||
// After key change, empty cart should still return empty arrays, not null
|
||||
expect($this->driver->getItems())->toBe([]);
|
||||
expect($this->driver->getConditions())->toBe([]);
|
||||
// And the session should not have null values written
|
||||
expect($this->session->get('new-key_cart_items'))->toBeNull();
|
||||
expect($this->session->get('new-key_cart_conditions'))->toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user