$constraints =
[new Range(['min' => 2, 'max' => 5
])];
$constraint =
new Expression( ['expression' => 'is_valid(this.data, a)', 'values' =>
['a' =>
$constraints]] );
$object =
new Entity();
$object->data = 7;
$this->
setObject($object);
$this->
expectFailingValueValidation( 0,
7,
$constraints,
null,
new ConstraintViolation('error_range', '',
[], '', '', 7, null, 'range'
) );
$this->validator->
validate($object,
$constraint);
$this->
assertCount(2,
$this->context->
getViolations());
}