Skip to content

Commit

Permalink
Update CartStoreTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Jul 1, 2024
1 parent 116a0b6 commit 21e79bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/Feature/CartStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@

test('can not store product in cart when item is not instance of cartable', function () {
$user = User::query()->create(['name' => 'Milwad', 'email' => '[email protected]']);
$product1 = new class extends \Illuminate\Database\Eloquent\Model {};
$user2 = User::query()->create(['name' => 'Binafy', 'email' => '[email protected]']);

$cart = Cart::query()->firstOrCreate(['user_id' => $user->id]);

$item['itemable'] = $product1;
$item['itemable'] = $user2;
$item['quantity'] = 2;

$cart->storeItem($item);
Expand All @@ -197,8 +197,8 @@
assertDatabaseCount('carts', 1);
assertDatabaseCount('cart_items', 0);
assertDatabaseMissing('cart_items', [
'itemable_id' => $product1->id,
'itemable_type' => $product1::class,
'itemable_id' => $user2->id,
'itemable_type' => $user2::class,
'quantity' => 2,
]);
})->expectExceptionMessage('The item must be an instance of Cartable');

0 comments on commit 21e79bb

Please sign in to comment.