diff --git a/tests/Unit/Services/CartItem/UpdateInCartTest.php b/tests/Unit/Services/CartItem/UpdateInCartTest.php index 6199323..757e697 100644 --- a/tests/Unit/Services/CartItem/UpdateInCartTest.php +++ b/tests/Unit/Services/CartItem/UpdateInCartTest.php @@ -6,6 +6,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Event; +use Tipoff\Checkout\Exceptions\CartNotValidException; use Tipoff\Checkout\Models\Cart; use Tipoff\Checkout\Models\CartItem; use Tipoff\Checkout\Tests\Support\Models\TestSellable; @@ -44,4 +45,17 @@ public function can_upsert_existing_cart_item() Event::assertDispatched(CartItemCreated::class, 1); Event::assertDispatched(CartItemUpdated::class, 1); } + + /** @test */ + public function cannot_upsert_cart_item() + { + $this->expectException(CartNotValidException::class); + + $cart = Cart::factory()->create(); + + $cartItem = Cart::createItem($this->sellable, 'item-id', 1234, 2); + $cart->upsertItem($cartItem); + + $this->cart->upsertItem($cartItem); + } }