ExpressionLanguageSyntax example


class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
{
    protected function createValidator(): ConstraintValidatorInterface
    {
        return new ExpressionLanguageSyntaxValidator(new ExpressionLanguage());
    }

    public function testExpressionValid()
    {
        $this->validator->validate('1 + 1', new ExpressionLanguageSyntax([
            'message' => 'myMessage',
            'allowedVariables' => [],
        ]));

        $this->assertNoViolation();
    }

    public function testExpressionWithoutNames()
    {
        $this->validator->validate('1 + 1', new ExpressionLanguageSyntax([
            'message' => 'myMessage',
        ]));
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;

/** * @group legacy */
class ExpressionLanguageSyntaxTest extends TestCase
{
    public function testValidatedByStandardValidator()
    {
        $constraint = new ExpressionLanguageSyntax();

        self::assertSame(ExpressionLanguageSyntaxValidator::class$constraint->validatedBy());
    }

    /** * @dataProvider provideServiceValidatedConstraints */
    public function testValidatedByService(ExpressionLanguageSyntax $constraint)
    {
        self::assertSame('my_service', $constraint->validatedBy());
    }

    
Home | Imprint | This part of the site doesn't use cookies.