Merge branch '3.0'
* 3.0: The exception should be thrown if an object doesn't implement Traversable AND doesn't implement Countable, not when it doesn't implement Traversable but DOES implement Countable [Form] fix violation mapper tests [HttpKernel] Prevent a fatal error when DebugHandlersListener is used with a kernel with no terminateWithException() method don't rely on deprecated YAML parser feature
This commit is contained in:
commit
1f80683ab1
@ -143,7 +143,7 @@ class Question
|
||||
}
|
||||
|
||||
if (null !== $values && !is_array($values)) {
|
||||
if (!$values instanceof \Traversable || $values instanceof \Countable) {
|
||||
if (!$values instanceof \Traversable || !$values instanceof \Countable) {
|
||||
throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or an object implementing both `Countable` and `Traversable` interfaces.');
|
||||
}
|
||||
}
|
||||
|
@ -28,14 +28,14 @@ class YamlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$dumper = new YamlDumper($container = new ContainerBuilder());
|
||||
|
||||
$this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file');
|
||||
$this->assertEqualYamlStructure(file_get_contents(self::$fixturesPath.'/yaml/services1.yml'), $dumper->dump(), '->dump() dumps an empty container as an empty YAML file');
|
||||
}
|
||||
|
||||
public function testAddParameters()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container8.php';
|
||||
$dumper = new YamlDumper($container);
|
||||
$this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters');
|
||||
$this->assertEqualYamlStructure(file_get_contents(self::$fixturesPath.'/yaml/services8.yml'), $dumper->dump(), '->dump() dumps parameters');
|
||||
}
|
||||
|
||||
public function testAddService()
|
||||
|
@ -1552,12 +1552,14 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
||||
$parent->add($child2);
|
||||
$child2->add($grandChild);
|
||||
|
||||
$parent->submit(array());
|
||||
|
||||
$this->mapper->mapViolation($violation, $parent);
|
||||
|
||||
// The error occurred on the child of the second form with the same path
|
||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $child1->getErrors(), $child1->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $child2->getErrors(), $child2->getName().' should not have an error, but has one');
|
||||
$this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChild->getName().' should have an error, but has none');
|
||||
$this->assertEquals(array($this->getFormError($violation, $grandChild)), iterator_to_array($grandChild->getErrors()), $grandChild->getName().' should have an error, but has none');
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,9 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
}
|
||||
if (!$this->exceptionHandler) {
|
||||
if ($event instanceof KernelEvent) {
|
||||
$this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
|
||||
if (method_exists($event->getKernel(), 'terminateWithException')) {
|
||||
$this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
|
||||
}
|
||||
} elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) {
|
||||
$output = $event->getOutput();
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
|
@ -21,7 +21,10 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\ExceptionHandler;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\KernelEvent;
|
||||
use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
@ -62,6 +65,31 @@ class DebugHandlersListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]);
|
||||
}
|
||||
|
||||
public function testConfigureForHttpKernelWithNoTerminateWithException()
|
||||
{
|
||||
$listener = new DebugHandlersListener(null);
|
||||
$eHandler = new ErrorHandler();
|
||||
$event = new KernelEvent(
|
||||
$this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
|
||||
Request::create('/'),
|
||||
HttpKernelInterface::MASTER_REQUEST
|
||||
);
|
||||
|
||||
$exception = null;
|
||||
$h = set_exception_handler(array($eHandler, 'handleException'));
|
||||
try {
|
||||
$listener->configure($event);
|
||||
} catch (\Exception $exception) {
|
||||
}
|
||||
restore_exception_handler();
|
||||
|
||||
if (null !== $exception) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$this->assertNull($h);
|
||||
}
|
||||
|
||||
public function testConsoleEvent()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
|
Reference in New Issue
Block a user