fix(test): use Customer model for unauthorized BO access tests instead of undefined enum case [AUD-TST-003]

This commit is contained in:
Jérémy Munsch 2026-08-26 11:45:57 +02:00
parent 23682def0d
commit 418b4e1941
No known key found for this signature in database
GPG key ID: 2AAECDA6B7330F91
2 changed files with 9 additions and 8 deletions

View file

@ -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');
});
});
});

View file

@ -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');
});
});
});