1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6declare(strict_types=1);
7
8namespace Tests\Controllers\Store;
9
10use App\Models\Store\Order;
11use App\Models\Store\OrderItem;
12use App\Models\User;
13use Tests\TestCase;
14
15class CartControllerTest extends TestCase
16{
17 public function testEmpty(): void
18 {
19 $itemCount = 3;
20 $cart = Order::factory()->incart()->has(OrderItem::factory()->count($itemCount), 'items')->create();
21
22 $this->actAsUser($cart->user, true);
23
24 $this->expectCountChange(fn () => $cart->fresh()->items()->count(), -$itemCount);
25 $this->delete(route('store.cart.empty'))->assertSuccessful();
26 }
27
28 public function testEmptyNonexistent(): void
29 {
30 $user = User::factory()->create();
31 $this->actAsUser($user, true);
32
33 $this->delete(route('store.cart.empty'))->assertSuccessful();
34 }
35}