From 472d50504100a12b7e63f7b84f09683f5d6561ac Mon Sep 17 00:00:00 2001 From: Joel Male Date: Wed, 18 Sep 2024 15:56:12 +1000 Subject: [PATCH] wip: fix issue with conditions not being properly removed --- composer.json | 2 +- src/Cart.php | 5 +---- tests/Unit/CartConditionsTest.php | 6 +++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 8d7f696..90a47a5 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "wearepixel/laravel-cart", - "version": "1.0.9", + "version": "1.0.10", "description": "A cart implementation for Laravel", "keywords": [ "laravel", diff --git a/src/Cart.php b/src/Cart.php index 70f8826..6853670 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -406,9 +406,6 @@ public function removeCartCondition($conditionName) $conditions->pull($conditionName); - // reset indexes - $conditions = $conditions->values(); - $this->saveConditions($conditions); } @@ -736,7 +733,7 @@ protected function addItem($id, $item) /** * save the cart * - * @param $cart CartCollection + * @param $cart CartCollection */ protected function save($cart) { diff --git a/tests/Unit/CartConditionsTest.php b/tests/Unit/CartConditionsTest.php index 495b4b8..f375d3e 100644 --- a/tests/Unit/CartConditionsTest.php +++ b/tests/Unit/CartConditionsTest.php @@ -10,11 +10,11 @@ $events->shouldReceive('dispatch'); $this->cart = new Cart( - new SessionMock, + new SessionMock(), $events, 'cart', 'SAMPLESESSIONKEY', - require (__DIR__ . '/../Helpers/ConfigConditionsMock.php') + require(__DIR__ . '/../Helpers/ConfigConditionsMock.php') ); }); @@ -119,7 +119,7 @@ // now we should have only 1 condition left on that item expect($this->cart->getConditions())->toHaveCount(1, 'Item should have one condition left'); - expect($this->cart->getConditions()[0]->getName())->toEqual('Mother\'s Day Gift Pack'); + expect($this->cart->getConditions()->first()->getName())->toEqual('Mother\'s Day Gift Pack'); }); });