. */ namespace App\Tests\Validator\Constraints; use App\Validator\Constraints\ValidTheme; use App\Validator\Constraints\ValidThemeValidator; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class ValidThemeValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): ValidThemeValidator { return new ValidThemeValidator(['bootstrap', 'theme1', 'theme2']); } public function testAllowNull(): void { $this->validator->validate(null, new ValidTheme()); $this->assertNoViolation(); } public function testAllowEmpty(): void { $this->validator->validate('', new ValidTheme()); $this->assertNoViolation(); } public function testValidTheme(): void { $this->validator->validate('bootstrap', new ValidTheme()); $this->assertNoViolation(); } public function testInvalidTheme(): void { $this->validator->validate('invalid', new ValidTheme()); $this->buildViolation('validator.selected_theme_is_invalid') ->setParameter('{{ value }}', 'invalid') ->assertRaised(); } }