From 418b4e194141dfe5b0b35b676b8dfa2de7d8ab85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 26 Aug 2026 11:45:57 +0200 Subject: [PATCH] fix(test): use Customer model for unauthorized BO access tests instead of undefined enum case [AUD-TST-003] --- .../App/Http/Controllers/Bo/DiscountsControllerTest.php | 9 +++++---- .../App/Http/Controllers/Bo/ProductsControllerTest.php | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php b/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php index c70666f1..838898fa 100644 --- a/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php +++ b/tests/Feature/App/Http/Controllers/Bo/DiscountsControllerTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use App\Models\Customer; use App\Models\Discount; use App\Models\User; use Domain\Enums\DiscountType; @@ -105,12 +106,12 @@ describe('DiscountsController', function () { $response->assertRedirect('/bo/login'); }); - it('denies access to unauthorized user with customer role', function () { - $user = User::factory()->make(['role' => UserRole::Customer]); - $this->actingAs($user, 'backend'); + it('redirects frontend customer trying to access bo to login', function () { + $customer = new Customer(); + $this->actingAs($customer, 'frontend'); $response = $this->get('/bo/discounts'); - expect($response->status())->toBe(403); + $response->assertRedirect('/bo/login'); }); }); }); diff --git a/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php b/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php index 5ca31bbd..96a38eea 100644 --- a/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php +++ b/tests/Feature/App/Http/Controllers/Bo/ProductsControllerTest.php @@ -241,12 +241,12 @@ describe('ProductsController', function () { $response->assertRedirect('/bo/login'); }); - it('denies access to unauthorized user with customer role', function () { - $user = User::factory()->make(['role' => UserRole::Customer]); - $this->actingAs($user, 'backend'); + it('redirects frontend customer trying to access bo to login', function () { + $customer = new \Customer(); + $this->actingAs($customer, 'frontend'); $response = $this->get('/bo/products'); - expect($response->status())->toBe(403); + $response->assertRedirect('/bo/login'); }); }); });