merged branch bschussek/issue7371 (PR #7918)

This PR was merged into the 2.1 branch.

Discussion
----------

[Form] Fixed: String validation groups are never interpreted as callbacks

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7371
| License       | MIT
| Doc PR        | -

Commits
-------

7b2ebbf [Form] Fixed: String validation groups are never interpreted as callbacks
This commit is contained in:
Fabien Potencier 2013-05-03 13:08:49 +02:00
commit 1510faa96a
2 changed files with 19 additions and 1 deletions

View File

@ -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);
}

View File

@ -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();