✨ feat(revervation): [Ajoute la création de session de réservation et le flow] 🐛 fix(PurgeCommandTest): [Utilise addCommand au lieu de add pour les commandes] 📝 chore(deps): [Mise à jour des dépendances Composer et corrections] 🐛 fix(KeycloakAuthenticator): [Corrige le type nullable de l'exception start] ✨ feat(Customer): [Ajoute les sessions de commandes aux entités Customer] ♻️ refactor(AppLogger): [Refactorise l'AppLogger pour obtenir l'UserAgent] ✨ feat(FlowReserve): [Ajoute une action de validation du panier] ```
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Security;
|
|
|
|
use App\Entity\Account;
|
|
use App\Security\UserChecker;
|
|
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
#[AllowMockObjectsWithoutExpectations]
|
|
class UserCheckerTest extends TestCase
|
|
{
|
|
private $checker;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->checker = new UserChecker();
|
|
}
|
|
|
|
public function testCheckPreAuthActiveUser()
|
|
{
|
|
$user = $this->createMock(Account::class);
|
|
$user->method('isActif')->willReturn(true);
|
|
|
|
$this->checker->checkPreAuth($user);
|
|
$this->assertTrue(true); // No exception thrown
|
|
}
|
|
|
|
public function testCheckPreAuthInactiveUserThrowsException()
|
|
{
|
|
$user = $this->createMock(Account::class);
|
|
$user->method('isActif')->willReturn(false);
|
|
|
|
$this->expectException(CustomUserMessageAccountStatusException::class);
|
|
$this->expectExceptionMessage('Votre compte a été désactivé.');
|
|
|
|
$this->checker->checkPreAuth($user);
|
|
}
|
|
|
|
public function testCheckPreAuthNonAccountUserIgnores()
|
|
{
|
|
$user = $this->createMock(UserInterface::class);
|
|
|
|
$this->checker->checkPreAuth($user);
|
|
$this->assertTrue(true);
|
|
}
|
|
}
|