[FrameworkBundle] set the dispatcher in the console application
So events are really dispatched using the FrameworkBundle console application
This commit is contained in:
parent
176a3d435e
commit
e93fc7a2c0
@ -67,6 +67,8 @@ class Application extends BaseApplication
|
|||||||
{
|
{
|
||||||
$this->registerCommands();
|
$this->registerCommands();
|
||||||
|
|
||||||
|
$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));
|
||||||
|
|
||||||
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
|
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
|
||||||
$shell = new Shell($this);
|
$shell = new Shell($this);
|
||||||
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
|
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
|
||||||
|
@ -20,7 +20,7 @@ class ApplicationTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testBundleInterfaceImplementation()
|
public function testBundleInterfaceImplementation()
|
||||||
{
|
{
|
||||||
$bundle = $this->getMock("Symfony\Component\HttpKernel\Bundle\BundleInterface");
|
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
|
||||||
|
|
||||||
$kernel = $this->getKernel(array($bundle));
|
$kernel = $this->getKernel(array($bundle));
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
public function testBundleCommandsAreRegistered()
|
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');
|
$bundle->expects($this->once())->method('registerCommands');
|
||||||
|
|
||||||
$kernel = $this->getKernel(array($bundle));
|
$kernel = $this->getKernel(array($bundle));
|
||||||
@ -41,12 +41,31 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
private function getKernel(array $bundles)
|
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
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundles')
|
->method('getBundles')
|
||||||
->will($this->returnValue($bundles))
|
->will($this->returnValue($bundles))
|
||||||
;
|
;
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($container))
|
||||||
|
;
|
||||||
|
|
||||||
return $kernel;
|
return $kernel;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user