$formBuilder =
new FormBuilder( 'form',
null,
new EventDispatcher(),
new FormFactory(new FormRegistry([],
new ResolvedFormTypeFactory())),
[] );
$form =
$formBuilder->
getForm();
$cause =
new ConstraintViolation('Error 1!', null,
[], null, '', null, null, 'code1'
);
$form->
addError(new FormError('Error 1!', null,
[], null,
$cause));
$cause =
new ConstraintViolation('Error 2!', null,
[], null, '', null, null, 'code1'
);
$form->
addError(new FormError('Error 2!', null,
[], null,
$cause));
$cause =
new ConstraintViolation('Error 3!', null,
[], null, '', null, null, 'code2'
);
$form->
addError(new FormError('Error 3!', null,
[], null,
$cause));
$formErrors =
$form->
getErrors();
$specificFormErrors =
$formErrors->
findByCodes($code);
$this->
assertInstanceOf(FormErrorIterator::
class,
$specificFormErrors);
$this->
assertCount($violationsCount,
$specificFormErrors);
}