Merge branch '2.6' into 2.7

* 2.6:
  [Debug] Fix deprecated use of DebugClassLoader
  [Validator] Fixed Choice when an empty array is used in the "choices" option
This commit is contained in:
Nicolas Grekas 2015-04-24 17:36:44 +02:00
commit e0c6f444a3
4 changed files with 20 additions and 3 deletions

View File

@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Registers the file link format for the {@link \Symfony\Component\HttpKernel\DataCollector\DumpDataCollector\DumpDataCollector}.
* Registers the file link format for the {@link \Symfony\Component\HttpKernel\DataCollector\DumpDataCollector}.
*
* @author Christian Flothmann <christian.flothmann@xabbuh.de>
*/

View File

@ -98,7 +98,7 @@ class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
$symfonyAutoloader = new SymfonyClassLoader();
$symfonyAutoloader->addPrefixes($prefixes);
$debugClassLoader = new DebugClassLoader($symfonyAutoloader);
$debugClassLoader = new DebugClassLoader(array($symfonyAutoloader, 'loadClass'));
return array(
array(

View File

@ -37,7 +37,7 @@ class ChoiceValidator extends ConstraintValidator
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Choice');
}
if (!$constraint->choices && !$constraint->callback) {
if (!is_array($constraint->choices) && !$constraint->callback) {
throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice');
}

View File

@ -150,6 +150,23 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest
->assertRaised();
}
public function testInvalidChoiceEmptyChoices()
{
$constraint = new Choice(array(
// May happen when the choices are provided dynamically, e.g. from
// the DB or the model
'choices' => array(),
'message' => 'myMessage',
));
$this->validator->validate('baz', $constraint);
$this->buildViolation('myMessage')
->setParameter('{{ value }}', '"baz"')
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
->assertRaised();
}
public function testInvalidChoiceMultiple()
{
$constraint = new Choice(array(