[Form] Fixed: String validation groups are never interpreted as callbacks
This commit is contained in:
parent
3f5cffec8a
commit
7b2ebbfa41
@ -181,7 +181,7 @@ class FormValidator extends ConstraintValidator
|
||||
$groups = $form->getConfig()->getOption('validation_groups');
|
||||
|
||||
if (null !== $groups) {
|
||||
if (is_callable($groups)) {
|
||||
if (!is_string($groups) && is_callable($groups)) {
|
||||
$groups = call_user_func($groups, $form);
|
||||
}
|
||||
|
||||
|
@ -302,6 +302,24 @@ class FormValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->validator->validate($form, new Form());
|
||||
}
|
||||
|
||||
public function testDontExecuteFunctionNames()
|
||||
{
|
||||
$context = $this->getExecutionContext();
|
||||
$graphWalker = $context->getGraphWalker();
|
||||
$object = $this->getMock('\stdClass');
|
||||
$options = array('validation_groups' => 'header');
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
|
||||
$graphWalker->expects($this->once())
|
||||
->method('walkReference')
|
||||
->with($object, 'header', 'data', true);
|
||||
|
||||
$this->validator->initialize($context);
|
||||
$this->validator->validate($form, new Form());
|
||||
}
|
||||
|
||||
public function testHandleClosureValidationGroups()
|
||||
{
|
||||
$context = $this->getExecutionContext();
|
||||
|
Reference in New Issue
Block a user