Skip to content

Commit

Permalink
Update CartDeleteTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Jul 10, 2024
1 parent a7406a1 commit 5fed1b2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Feature/Models/CartDeleteTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Binafy\LaravelCart\Events\LaravelCartEmptyEvent;
use Binafy\LaravelCart\Events\LaravelCartRemoveItemEvent;
use Binafy\LaravelCart\Events\LaravelCartStoreItemEvent;
use Binafy\LaravelCart\Models\Cart;
Expand Down Expand Up @@ -66,6 +67,8 @@
});

test('can empty the cart', function () {
Event::fake();

$user = User::query()->create(['name' => 'Milwad', 'email' => 'milwad.dev@gmail.comd']);
$product1 = Product::query()->create(['title' => 'Product 1']);
$product2 = Product::query()->create(['title' => 'Product 2']);
Expand Down Expand Up @@ -100,4 +103,8 @@
// Remove all items from cart
$cart->emptyCart();
assertDatabaseCount('cart_items', 0);

// Event Assertions
Event::assertDispatched(LaravelCartStoreItemEvent::class);
Event::assertDispatched(LaravelCartEmptyEvent::class);
});

0 comments on commit 5fed1b2

Please sign in to comment.