Navigation Menu

Skip to content

Commit

Permalink
[Form] Fixed: String validation groups are never interpreted as callb…
Browse files Browse the repository at this point in the history
…acks
  • Loading branch information
webmozart committed May 3, 2013
1 parent 3f5cffe commit 7b2ebbf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -181,7 +181,7 @@ private static function getValidationGroups(FormInterface $form)
$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);
}

Expand Down
Expand Up @@ -302,6 +302,24 @@ public function testHandleCallbackValidationGroups()
$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();
Expand Down

0 comments on commit 7b2ebbf

Please sign in to comment.