From c8d387f13184e220bc64aca59474db2221465bce Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 16 Feb 2016 09:56:31 +0100 Subject: [PATCH 1/4] don't rely on deprecated YAML parser feature --- .../DependencyInjection/Tests/Dumper/YamlDumperTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php index aec4109f24..5c61e4be2e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php @@ -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() From 2849152c5e975fbf349a848d7d8b684c22977201 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 16 Feb 2016 16:21:16 +0000 Subject: [PATCH 2/4] [HttpKernel] Prevent a fatal error when DebugHandlersListener is used with a kernel with no terminateWithException() method --- .../EventListener/DebugHandlersListener.php | 4 ++- .../DebugHandlersListenerTest.php | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 19a4c6d945..2f523a54db 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -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) { diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index 4584a48a76..8e1c35b345 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -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(); From f87558d05ea7fbd5ee5761cbc03b29dd7da2a9b8 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 16 Feb 2016 20:34:40 +0100 Subject: [PATCH 3/4] [Form] fix violation mapper tests This takes into account the changes to the `getErrors()` in Symfony 2.5 (the method rturns a `FormErrorIterator` instead of an array) as well as the fact that non-submitted forms do not accept errors since #10567 anymore. --- .../Validator/ViolationMapper/ViolationMapperTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index 1dc90e85da..a099e10459 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -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'); } } From 8eea65e0d86c8ef7611f16927ff68246bd4fe810 Mon Sep 17 00:00:00 2001 From: Robin Kanters Date: Tue, 16 Feb 2016 15:02:44 +0100 Subject: [PATCH 4/4] 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 --- src/Symfony/Component/Console/Question/Question.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index ffe9417117..02b190caed 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -140,7 +140,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.'); } }