Skip to content

Commit 1f80683

Browse files
committed
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
2 parents 6e0d085 + 0923bc8 commit 1f80683

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

src/Symfony/Component/Console/Question/Question.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function setAutocompleterValues($values)
143143
}
144144

145145
if (null !== $values && !is_array($values)) {
146-
if (!$values instanceof \Traversable || $values instanceof \Countable) {
146+
if (!$values instanceof \Traversable || !$values instanceof \Countable) {
147147
throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or an object implementing both `Countable` and `Traversable` interfaces.');
148148
}
149149
}

src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public function testDump()
2828
{
2929
$dumper = new YamlDumper($container = new ContainerBuilder());
3030

31-
$this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file');
31+
$this->assertEqualYamlStructure(file_get_contents(self::$fixturesPath.'/yaml/services1.yml'), $dumper->dump(), '->dump() dumps an empty container as an empty YAML file');
3232
}
3333

3434
public function testAddParameters()
3535
{
3636
$container = include self::$fixturesPath.'/containers/container8.php';
3737
$dumper = new YamlDumper($container);
38-
$this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters');
38+
$this->assertEqualYamlStructure(file_get_contents(self::$fixturesPath.'/yaml/services8.yml'), $dumper->dump(), '->dump() dumps parameters');
3939
}
4040

4141
public function testAddService()

src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,12 +1552,14 @@ public function testBacktrackIfSeveralSubFormsWithSamePropertyPath()
15521552
$parent->add($child2);
15531553
$child2->add($grandChild);
15541554

1555+
$parent->submit(array());
1556+
15551557
$this->mapper->mapViolation($violation, $parent);
15561558

15571559
// The error occurred on the child of the second form with the same path
15581560
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
15591561
$this->assertCount(0, $child1->getErrors(), $child1->getName().' should not have an error, but has one');
15601562
$this->assertCount(0, $child2->getErrors(), $child2->getName().' should not have an error, but has one');
1561-
$this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChild->getName().' should have an error, but has none');
1563+
$this->assertEquals(array($this->getFormError($violation, $grandChild)), iterator_to_array($grandChild->getErrors()), $grandChild->getName().' should have an error, but has none');
15621564
}
15631565
}

src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public function configure(Event $event = null)
9393
}
9494
if (!$this->exceptionHandler) {
9595
if ($event instanceof KernelEvent) {
96-
$this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
96+
if (method_exists($event->getKernel(), 'terminateWithException')) {
97+
$this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
98+
}
9799
} elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) {
98100
$output = $event->getOutput();
99101
if ($output instanceof ConsoleOutputInterface) {

src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
use Symfony\Component\Debug\ErrorHandler;
2222
use Symfony\Component\Debug\ExceptionHandler;
2323
use Symfony\Component\EventDispatcher\EventDispatcher;
24+
use Symfony\Component\HttpFoundation\Request;
25+
use Symfony\Component\HttpKernel\Event\KernelEvent;
2426
use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener;
27+
use Symfony\Component\HttpKernel\HttpKernelInterface;
2528
use Symfony\Component\HttpKernel\KernelEvents;
2629

2730
/**
@@ -62,6 +65,31 @@ public function testConfigure()
6265
$this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]);
6366
}
6467

68+
public function testConfigureForHttpKernelWithNoTerminateWithException()
69+
{
70+
$listener = new DebugHandlersListener(null);
71+
$eHandler = new ErrorHandler();
72+
$event = new KernelEvent(
73+
$this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
74+
Request::create('/'),
75+
HttpKernelInterface::MASTER_REQUEST
76+
);
77+
78+
$exception = null;
79+
$h = set_exception_handler(array($eHandler, 'handleException'));
80+
try {
81+
$listener->configure($event);
82+
} catch (\Exception $exception) {
83+
}
84+
restore_exception_handler();
85+
86+
if (null !== $exception) {
87+
throw $exception;
88+
}
89+
90+
$this->assertNull($h);
91+
}
92+
6593
public function testConsoleEvent()
6694
{
6795
$dispatcher = new EventDispatcher();

0 commit comments

Comments
 (0)