Skip to content

Commit

Permalink
Merge branch '2.8'
Browse files Browse the repository at this point in the history
* 2.8:
  [Debug] Fix deprecated use of DebugClassLoader
  Revert "[HttpKernel] Throw a LogicException when kernel.exception does not led to a Response"
  [Validator] Fixed Choice when an empty array is used in the "choices" option
  • Loading branch information
nicolas-grekas committed Apr 24, 2015
2 parents 6b738fd + e6d05b7 commit 32fa910
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
Expand Up @@ -15,7 +15,7 @@
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>
*/
Expand Down
Expand Up @@ -73,7 +73,7 @@ public function provideClassNotFoundData()
$symfonyAutoloader = new SymfonyClassLoader();
$symfonyAutoloader->addPrefixes($prefixes);

$debugClassLoader = new DebugClassLoader($symfonyAutoloader);
$debugClassLoader = new DebugClassLoader(array($symfonyAutoloader, 'loadClass'));

return array(
array(
Expand Down
4 changes: 0 additions & 4 deletions src/Symfony/Component/HttpKernel/HttpKernel.php
Expand Up @@ -229,10 +229,6 @@ private function handleException(\Exception $e, $request, $type)
if (!$event->hasResponse()) {
$this->finishRequest($request, $type);

if ($this->dispatcher->hasListeners(KernelEvents::EXCEPTION)) {
throw new \LogicException('No listeners of the "kernel.exception" event set a Response', 0, $e);
}

throw $e;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
Expand Up @@ -151,7 +151,7 @@ public function testHandleWhenNoControllerIsFound()
$dispatcher = new EventDispatcher();
$kernel = new HttpKernel($dispatcher, $this->getResolver(false));

$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false);
$kernel->handle(new Request());
}

/**
Expand Down
Expand Up @@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint)
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');
}

Expand Down
Expand Up @@ -150,6 +150,23 @@ public function testInvalidChoice()
->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(
Expand Down

0 comments on commit 32fa910

Please sign in to comment.