Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0c6f44

Browse files
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
2 parents 1b34f2c + dc86ff7 commit e0c6f44

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/Symfony/Bundle/DebugBundle/DependencyInjection/Compiler/DumpDataCollectorPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616

1717
/**
18-
* Registers the file link format for the {@link \Symfony\Component\HttpKernel\DataCollector\DumpDataCollector\DumpDataCollector}.
18+
* Registers the file link format for the {@link \Symfony\Component\HttpKernel\DataCollector\DumpDataCollector}.
1919
*
2020
* @author Christian Flothmann <[email protected]>
2121
*/

src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function provideClassNotFoundData()
9898
$symfonyAutoloader = new SymfonyClassLoader();
9999
$symfonyAutoloader->addPrefixes($prefixes);
100100

101-
$debugClassLoader = new DebugClassLoader($symfonyAutoloader);
101+
$debugClassLoader = new DebugClassLoader(array($symfonyAutoloader, 'loadClass'));
102102

103103
return array(
104104
array(

src/Symfony/Component/Validator/Constraints/ChoiceValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint)
3737
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Choice');
3838
}
3939

40-
if (!$constraint->choices && !$constraint->callback) {
40+
if (!is_array($constraint->choices) && !$constraint->callback) {
4141
throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice');
4242
}
4343

src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,23 @@ public function testInvalidChoice()
150150
->assertRaised();
151151
}
152152

153+
public function testInvalidChoiceEmptyChoices()
154+
{
155+
$constraint = new Choice(array(
156+
// May happen when the choices are provided dynamically, e.g. from
157+
// the DB or the model
158+
'choices' => array(),
159+
'message' => 'myMessage',
160+
));
161+
162+
$this->validator->validate('baz', $constraint);
163+
164+
$this->buildViolation('myMessage')
165+
->setParameter('{{ value }}', '"baz"')
166+
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
167+
->assertRaised();
168+
}
169+
153170
public function testInvalidChoiceMultiple()
154171
{
155172
$constraint = new Choice(array(

0 commit comments

Comments
 (0)