Skip to content

Commit

Permalink
[FrameworkBundle] set the dispatcher in the console application
Browse files Browse the repository at this point in the history
So events are really dispatched using the FrameworkBundle console application
  • Loading branch information
Tobion committed May 28, 2013
1 parent 176a3d4 commit e93fc7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Expand Up @@ -67,6 +67,8 @@ public function doRun(InputInterface $input, OutputInterface $output)
{
$this->registerCommands();

$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));

if (true === $input->hasParameterOption(array('--shell', '-s'))) {
$shell = new Shell($this);
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
Expand Down
Expand Up @@ -20,7 +20,7 @@ class ApplicationTest extends TestCase
{
public function testBundleInterfaceImplementation()
{
$bundle = $this->getMock("Symfony\Component\HttpKernel\Bundle\BundleInterface");
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');

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

Expand All @@ -30,7 +30,7 @@ public function testBundleInterfaceImplementation()

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

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

private function getKernel(array $bundles)
{
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher
->expects($this->atLeastOnce())
->method('dispatch')
;

$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container
->expects($this->once())
->method('get')
->with($this->equalTo('event_dispatcher'))
->will($this->returnValue($dispatcher))
;

$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue($bundles))
;
$kernel
->expects($this->any())
->method('getContainer')
->will($this->returnValue($container))
;

return $kernel;
}
Expand Down

0 comments on commit e93fc7a

Please sign in to comment.