Added a method to erase stored cart

This commit is contained in:
Cristian
2019-10-31 13:14:22 +01:00
committed by sartoric
parent fe5fe942c2
commit bb59a2e2dd
3 changed files with 54 additions and 0 deletions

View File

@@ -1189,6 +1189,28 @@ class CartTest extends TestCase
$this->assertEquals('large', $cartItem->options->size);
}
/** @test */
public function it_can_erase_a_cart_from_the_database()
{
$this->artisan('migrate', [
'--database' => 'testing',
]);
Event::fake();
$cart = $this->getCart();
$cart->add(new BuyableProduct());
$cart->store($identifier = 123);
$cart->erase($identifier);
$this->assertDatabaseMissing('shoppingcart', ['identifier' => $identifier, 'instance' => 'default']);
Event::assertDispatched('cart.erased');
}
/**
* Get an instance of the cart.
*