-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
116a0b6
commit 21e79bb
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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'); |