From 65280168a4a66025ee7e7e55a4441c7cc8386f0c Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sun, 18 Jun 2023 17:41:12 +0300 Subject: [PATCH] Update CartTest to remove the temporary cart. --- tests/Feature/CartTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/Feature/CartTest.php b/tests/Feature/CartTest.php index 31da381..24263e1 100644 --- a/tests/Feature/CartTest.php +++ b/tests/Feature/CartTest.php @@ -84,6 +84,29 @@ class CartTest extends TestCase ]); } + public function test_removing_cart(): void + { + $this->test_user = User::where('username', $this->test_user_username)->first(); + $this->test_city = City::where('name', $this->test_city_name2)->first(); + + $this->assertNotNull($this->test_user); + $this->assertNotNull($this->test_city); + + $cart = Cart::where('status', 'CART') + ->where('user_id', $this->test_user->id) + ->where('city_id', $this->test_city->id) + ->first(); + $cart->delete(); + + $this->assertNotNull($cart); + + $this->assertDatabaseMissing('carts', [ + 'status' => 'CART', + 'user_id' => $this->test_user->id, + 'city_id'=> $this->test_city->id + ]); + } + public function test_select_city_with_no_city(): void { $this->test_city = City::where('name', $this->test_city_name2)->first();