From 0c27ac4d9a87e1fd5b975b179c93583c21d42338 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Wed, 27 May 2026 21:09:40 +1000 Subject: [PATCH] test: update existing tests to use CartDriver --- tests/Unit/CartConditionsTest.php | 4 ++-- tests/Unit/CartTest.php | 4 ++-- tests/Unit/CartTestEventsTest.php | 19 +++++++------------ tests/Unit/CartTestMultipleInstancesTest.php | 7 +++---- tests/Unit/DatabaseCartTest.php | 12 ++++++++---- tests/Unit/ItemTest.php | 4 ++-- tests/Unit/ItemTestOtherFormatTest.php | 4 ++-- 7 files changed, 26 insertions(+), 28 deletions(-) diff --git a/tests/Unit/CartConditionsTest.php b/tests/Unit/CartConditionsTest.php index 333dba7..0cc494c 100644 --- a/tests/Unit/CartConditionsTest.php +++ b/tests/Unit/CartConditionsTest.php @@ -3,6 +3,7 @@ use Wearepixel\Cart\Cart; use Wearepixel\Cart\CartCondition; use Wearepixel\Cart\CartConditionCollection; +use Wearepixel\Cart\Drivers\SessionDriver; use Wearepixel\Cart\Tests\Helpers\SessionMock; beforeEach(function () { @@ -10,10 +11,9 @@ $events->shouldReceive('dispatch'); $this->cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigConditionsMock.php') ); }); diff --git a/tests/Unit/CartTest.php b/tests/Unit/CartTest.php index 509c567..dd47fd9 100644 --- a/tests/Unit/CartTest.php +++ b/tests/Unit/CartTest.php @@ -1,6 +1,7 @@ shouldReceive('dispatch'); $this->cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'shopping', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); }); diff --git a/tests/Unit/CartTestEventsTest.php b/tests/Unit/CartTestEventsTest.php index 6bc0ead..88b45e4 100644 --- a/tests/Unit/CartTestEventsTest.php +++ b/tests/Unit/CartTestEventsTest.php @@ -1,6 +1,7 @@ shouldReceive('dispatch')->once()->with('LaravelCart.Created', Mockery::type('array'), true); $cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); @@ -31,10 +31,9 @@ $events->shouldReceive('dispatch')->once()->with('LaravelCart.Added', Mockery::type('array'), true); $cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); @@ -50,10 +49,9 @@ $events->shouldReceive('dispatch')->times(2)->with('LaravelCart.Added', Mockery::type('array'), true); $cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); @@ -94,10 +92,9 @@ ]; $cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); @@ -139,10 +136,9 @@ ]; $cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); @@ -186,10 +182,9 @@ ]; $cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); diff --git a/tests/Unit/CartTestMultipleInstancesTest.php b/tests/Unit/CartTestMultipleInstancesTest.php index eb1017c..b9fcdf9 100644 --- a/tests/Unit/CartTestMultipleInstancesTest.php +++ b/tests/Unit/CartTestMultipleInstancesTest.php @@ -1,6 +1,7 @@ shouldReceive('dispatch'); $this->cart1 = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'uniquesessionkey123'), $events, 'shopping', - 'uniquesessionkey123', require (__DIR__ . '/../Helpers/ConfigMock.php') ); $this->cart2 = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'uniquesessionkey456'), $events, 'wishlist', - 'uniquesessionkey456', require (__DIR__ . '/../Helpers/ConfigMock.php') ); }); diff --git a/tests/Unit/DatabaseCartTest.php b/tests/Unit/DatabaseCartTest.php index ac8f37a..8080374 100644 --- a/tests/Unit/DatabaseCartTest.php +++ b/tests/Unit/DatabaseCartTest.php @@ -2,19 +2,23 @@ use Wearepixel\Cart\Cart; use Wearepixel\Cart\CartCondition; +use Wearepixel\Cart\Drivers\DatabaseDriver; use Wearepixel\Cart\Tests\Helpers\MockCartModel; beforeEach(function () { $events = Mockery::mock('Illuminate\Contracts\Events\Dispatcher'); $events->shouldReceive('dispatch'); - $storage = new MockCartModel; - $this->cart = new Cart( - $storage, + new DatabaseDriver( + MockCartModel::class, + 'session_id', + 'items', + 'conditions', + 'SAMPLESESSIONKEY', + ), $events, 'cart', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigDatabaseMock.php') ); }); diff --git a/tests/Unit/ItemTest.php b/tests/Unit/ItemTest.php index fd18d39..a35febd 100644 --- a/tests/Unit/ItemTest.php +++ b/tests/Unit/ItemTest.php @@ -2,6 +2,7 @@ use Wearepixel\Cart\Cart; use Wearepixel\Cart\CartCondition; +use Wearepixel\Cart\Drivers\SessionDriver; use Wearepixel\Cart\Tests\Helpers\MockProduct; use Wearepixel\Cart\Tests\Helpers\SessionMock; @@ -10,10 +11,9 @@ $events->shouldReceive('dispatch'); $this->cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'shopping', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMock.php') ); }); diff --git a/tests/Unit/ItemTestOtherFormatTest.php b/tests/Unit/ItemTestOtherFormatTest.php index 928e8af..0852d60 100644 --- a/tests/Unit/ItemTestOtherFormatTest.php +++ b/tests/Unit/ItemTestOtherFormatTest.php @@ -1,6 +1,7 @@ shouldReceive('dispatch'); $this->cart = new Cart( - new SessionMock, + new SessionDriver(new SessionMock, 'SAMPLESESSIONKEY'), $events, 'shopping', - 'SAMPLESESSIONKEY', require (__DIR__ . '/../Helpers/ConfigMockOtherFormat.php') ); });