From bc25ee6f3cfbb32d21b8e09a34a66a2814f93fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 26 Aug 2026 11:52:08 +0200 Subject: [PATCH] fix(test): explicitly logout backend guard in customer rejection tests and add phpdoc typehints --- .../App/Http/Controllers/Bo/DiscountsControllerTest.php | 3 +++ .../App/Http/Controllers/Bo/ProductsControllerTest.php | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php b/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php index 838898fa..32bbd1ea 100644 --- a/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php +++ b/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php @@ -100,6 +100,7 @@ describe('DiscountsController', function () { describe('authorization rejections', function () { it('redirects unauthenticated guest to login', function () { + /** @var \Tests\TestCase $this */ auth('backend')->logout(); $response = $this->get('/bo/discounts'); @@ -107,6 +108,8 @@ describe('DiscountsController', function () { }); it('redirects frontend customer trying to access bo to login', function () { + /** @var \Tests\TestCase $this */ + auth('backend')->logout(); $customer = new Customer(); $this->actingAs($customer, 'frontend'); diff --git a/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php b/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php index 96a38eea..b6c8b661 100644 --- a/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php +++ b/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use App\Models\Customer; use App\Models\Product; use App\Models\Range; use App\Models\Tag; @@ -18,6 +19,7 @@ describe('ProductsController', function () { beforeEach(function () { // GIVEN + /** @var \Tests\TestCase $this */ $this->user = User::factory()->create(['role' => UserRole::SuperAdmin]); $this->actingAs($this->user, 'backend'); }); @@ -235,6 +237,7 @@ describe('ProductsController', function () { describe('authorization rejections', function () { it('redirects unauthenticated guest to login', function () { + /** @var \Tests\TestCase $this */ auth('backend')->logout(); $response = $this->get('/bo/products'); @@ -242,7 +245,9 @@ describe('ProductsController', function () { }); it('redirects frontend customer trying to access bo to login', function () { - $customer = new \Customer(); + /** @var \Tests\TestCase $this */ + auth('backend')->logout(); + $customer = new Customer(); $this->actingAs($customer, 'frontend'); $response = $this->get('/bo/products');