From 3fdf23364c2e58772b543dad2cbc5fb43e479890 Mon Sep 17 00:00:00 2001 From: Milwad <98118400+milwad-dev@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:30:09 +0330 Subject: [PATCH] pint --- src/Drivers/LaravelCartSession.php | 2 +- tests/Feature/Manager/Session/CartDeleteTest.php | 3 --- tests/Feature/Manager/Session/CartStoreTest.php | 4 ---- .../Manager/Session/CartUpdateQuantityTest.php | 16 ++++++---------- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/Drivers/LaravelCartSession.php b/src/Drivers/LaravelCartSession.php index 5f9aee6..a3e1ad9 100644 --- a/src/Drivers/LaravelCartSession.php +++ b/src/Drivers/LaravelCartSession.php @@ -132,7 +132,7 @@ protected function getCart(?int $userId = null): array */ protected function sessionKey(int $userId): string { - return self::SESSION_KEY_PREFIX . $userId; + return self::SESSION_KEY_PREFIX.$userId; } /** diff --git a/tests/Feature/Manager/Session/CartDeleteTest.php b/tests/Feature/Manager/Session/CartDeleteTest.php index e1c5f2d..5f2c974 100644 --- a/tests/Feature/Manager/Session/CartDeleteTest.php +++ b/tests/Feature/Manager/Session/CartDeleteTest.php @@ -2,12 +2,9 @@ use Binafy\LaravelCart\LaravelCart; use Binafy\LaravelCart\Models\Cart; -use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\SetUp\Models\Product; use Tests\SetUp\Models\User; -use function Pest\Laravel\assertDatabaseCount; - test('can remove an item from the cart with facade', function () { $user = User::query()->create(['name' => 'Milwad', 'email' => 'milwad.dev@gmail.comd']); auth()->login($user); diff --git a/tests/Feature/Manager/Session/CartStoreTest.php b/tests/Feature/Manager/Session/CartStoreTest.php index d37ba28..937700a 100644 --- a/tests/Feature/Manager/Session/CartStoreTest.php +++ b/tests/Feature/Manager/Session/CartStoreTest.php @@ -1,13 +1,9 @@ flush(); }); diff --git a/tests/Feature/Manager/Session/CartUpdateQuantityTest.php b/tests/Feature/Manager/Session/CartUpdateQuantityTest.php index f739389..2fb88cb 100644 --- a/tests/Feature/Manager/Session/CartUpdateQuantityTest.php +++ b/tests/Feature/Manager/Session/CartUpdateQuantityTest.php @@ -2,14 +2,10 @@ use Binafy\LaravelCart\LaravelCart; use Binafy\LaravelCart\Models\Cart; -use Binafy\LaravelCart\Models\CartItem; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\SetUp\Models\Product; use Tests\SetUp\Models\User; -use function Pest\Laravel\assertDatabaseHas; -use function Pest\Laravel\assertDatabaseMissing; - /* * Use `RefreshDatabase` for delete migration data for each test. */ @@ -47,12 +43,12 @@ 'quantity' => 3, ], 2); - expect(session("cart_2")[0]['quantity'])->toBe(3); + expect(session('cart_2')[0]['quantity'])->toBe(3); // Increase quantity LaravelCart::driver('session')->decreaseQuantity($product, 2, 2); - expect(session("cart_2")[0]['quantity'])->toBe(1); + expect(session('cart_2')[0]['quantity'])->toBe(1); }); test('can not increase quantity of the item in cart with facade when item not found', function () { @@ -68,12 +64,12 @@ 'quantity' => 1, ], 2); - expect(session("cart_2")[0]['quantity'])->toBe(1); + expect(session('cart_2')[0]['quantity'])->toBe(1); // Increase quantity LaravelCart::driver('session')->increaseQuantity($product2, 2); - expect(session("cart_2")[0]['quantity'])->toBe(1); + expect(session('cart_2')[0]['quantity'])->toBe(1); })->expectExceptionMessage('The item not found'); test('can not decrease quantity of the item in cart with facade when item not found', function () { @@ -89,10 +85,10 @@ 'quantity' => 3, ], 2); - expect(session("cart_2")[0]['quantity'])->toBe(3); + expect(session('cart_2')[0]['quantity'])->toBe(3); // Decrease quantity LaravelCart::driver('session')->decreaseQuantity($product2, 2); - expect(session("cart_2")[0]['quantity'])->toBe(3); + expect(session('cart_2')[0]['quantity'])->toBe(3); })->expectExceptionMessage('The item not found');