mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 22:01:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7427ce953a | ||
|
|
6ba50a1c48 | ||
|
|
fce7125c5f | ||
|
|
834e211443 | ||
|
|
9b198edb7d | ||
|
|
49959faace |
@@ -18,10 +18,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
|
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php }}
|
php-version: ${{ matrix.php }}
|
||||||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached
|
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wearepixel/laravel-cart",
|
"name": "wearepixel/laravel-cart",
|
||||||
"version": "2.1.3",
|
"version": "2.1.4",
|
||||||
"description": "A cart implementation for Laravel",
|
"description": "A cart implementation for Laravel",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"laravel",
|
"laravel",
|
||||||
|
|||||||
+2
-4
@@ -159,10 +159,8 @@ public function clear()
|
|||||||
|
|
||||||
$deleted = $this->session->delete();
|
$deleted = $this->session->delete();
|
||||||
|
|
||||||
$this->session = [
|
$this->session[$this->itemsKey] = [];
|
||||||
$this->itemsKey => [],
|
$this->session[$this->conditionsKey] = [];
|
||||||
$this->conditionsKey => [],
|
|
||||||
];
|
|
||||||
|
|
||||||
return $deleted;
|
return $deleted;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,4 +123,23 @@
|
|||||||
expect($this->cart->getContent()->count())->toEqual(0, 'Cart content should be 0');
|
expect($this->cart->getContent()->count())->toEqual(0, 'Cart content should be 0');
|
||||||
expect(MockCartModel::all()->count())->toEqual(0, 'The carts database table should have 0 rows');
|
expect(MockCartModel::all()->count())->toEqual(0, 'The carts database table should have 0 rows');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('can clear cart conditions after clearing the cart', function () {
|
||||||
|
$condition = new CartCondition([
|
||||||
|
'name' => '10% Off',
|
||||||
|
'type' => 'coupon',
|
||||||
|
'target' => 'subtotal',
|
||||||
|
'value' => '-10%',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->cart->add(1, 'Sample Item', 100.99, 2, []);
|
||||||
|
$this->cart->condition($condition);
|
||||||
|
|
||||||
|
$this->cart->clear();
|
||||||
|
|
||||||
|
// This was throwing "Call to a member function save() on array"
|
||||||
|
// because clear() replaced $this->session with a plain array
|
||||||
|
expect(fn () => $this->cart->clearCartConditions())->not->toThrow(Error::class);
|
||||||
|
expect($this->cart->getConditions())->toBeEmpty();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user