Skip to content

Commit 18e8733

Browse files
committed
merged branch Tobion/console-dispatcher (PR #8158)
This PR was merged into the 2.3 branch. Discussion ---------- [FrameworkBundle] set the dispatcher in the console application BC break: no test pass: yes Otherwise events are not dispatched in symfony frameworkbundle. The first commit fixes a related typehint in the console. Commits ------- e93fc7a [FrameworkBundle] set the dispatcher in the console application 176a3d4 [Console] fix typehint for Application::setDispatcher
2 parents 39ac48c + 21fd89f commit 18e8733

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

Console/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public function doRun(InputInterface $input, OutputInterface $output)
6767
{
6868
$this->registerCommands();
6969

70+
$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));
71+
7072
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
7173
$shell = new Shell($this);
7274
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));

Tests/Console/ApplicationTest.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ApplicationTest extends TestCase
2020
{
2121
public function testBundleInterfaceImplementation()
2222
{
23-
$bundle = $this->getMock("Symfony\Component\HttpKernel\Bundle\BundleInterface");
23+
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
2424

2525
$kernel = $this->getKernel(array($bundle));
2626

@@ -30,7 +30,7 @@ public function testBundleInterfaceImplementation()
3030

3131
public function testBundleCommandsAreRegistered()
3232
{
33-
$bundle = $this->getMock("Symfony\Component\HttpKernel\Bundle\Bundle");
33+
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
3434
$bundle->expects($this->once())->method('registerCommands');
3535

3636
$kernel = $this->getKernel(array($bundle));
@@ -41,12 +41,31 @@ public function testBundleCommandsAreRegistered()
4141

4242
private function getKernel(array $bundles)
4343
{
44-
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
44+
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
45+
$dispatcher
46+
->expects($this->atLeastOnce())
47+
->method('dispatch')
48+
;
49+
50+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
51+
$container
52+
->expects($this->once())
53+
->method('get')
54+
->with($this->equalTo('event_dispatcher'))
55+
->will($this->returnValue($dispatcher))
56+
;
57+
58+
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
4559
$kernel
4660
->expects($this->any())
4761
->method('getBundles')
4862
->will($this->returnValue($bundles))
4963
;
64+
$kernel
65+
->expects($this->any())
66+
->method('getContainer')
67+
->will($this->returnValue($container))
68+
;
5069

5170
return $kernel;
5271
}

0 commit comments

Comments
 (0)