. */ declare(strict_types=1); namespace App\Tests\Security; use App\Entity\UserSystem\User; use App\Security\UserChecker; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException; class UserCheckerTest extends WebTestCase { protected $service; protected function setUp(): void { self::bootKernel(); $this->service = self::getContainer()->get(UserChecker::class); } public function testThrowDisabledException(): void { $user = new User(); $user->setDisabled(false); //A user that is not disabled should not throw an exception $this->service->checkPostAuth($user); //A disabled user must throw an exception $user->setDisabled(true); $this->expectException(CustomUserMessageAccountStatusException::class); $this->service->checkPostAuth($user); } }