[2.7] [FrameworkBundle] minor fix tests added by #17569

This commit is contained in:
Jules Pietri 2016-02-19 17:41:56 +01:00
parent 653428af76
commit ce6e5ac5aa

View File

@ -24,7 +24,7 @@ class ApplicationTest extends TestCase
{
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
$kernel = $this->getKernel(array($bundle));
$kernel = $this->getKernel(array($bundle), true);
$application = new Application($kernel);
$application->doRun(new ArrayInput(array('list')), new NullOutput());
@ -35,7 +35,7 @@ class ApplicationTest extends TestCase
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');
$kernel = $this->getKernel(array($bundle));
$kernel = $this->getKernel(array($bundle), true);
$application = new Application($kernel);
$application->doRun(new ArrayInput(array('list')), new NullOutput());
@ -49,12 +49,7 @@ class ApplicationTest extends TestCase
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));
$application = new Application($kernel);
$application->all();
@ -68,12 +63,7 @@ class ApplicationTest extends TestCase
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));
$application = new Application($kernel);
@ -88,12 +78,7 @@ class ApplicationTest extends TestCase
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));
$application = new Application($kernel);
@ -108,12 +93,7 @@ class ApplicationTest extends TestCase
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));
$application = new Application($kernel);
@ -130,7 +110,7 @@ class ApplicationTest extends TestCase
$command->setCode(function () {});
$command->expects($this->exactly(2))->method('setContainer');
$application = new Application($this->getKernel(array()));
$application = new Application($this->getKernel(array(), true));
$application->setAutoExit(false);
$application->setCatchExceptions(false);
$application->add($command);
@ -143,21 +123,23 @@ class ApplicationTest extends TestCase
$tester->run(array('command' => 'foo'));
}
private function getKernel(array $bundles)
private function getKernel(array $bundles, $useDispatcher = false)
{
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher
->expects($this->atLeastOnce())
->method('dispatch')
;
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container
->expects($this->atLeastOnce())
->method('get')
->with($this->equalTo('event_dispatcher'))
->will($this->returnValue($dispatcher))
;
if ($useDispatcher) {
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher
->expects($this->atLeastOnce())
->method('dispatch')
;
$container
->expects($this->atLeastOnce())
->method('get')
->with($this->equalTo('event_dispatcher'))
->will($this->returnValue($dispatcher));
}
$container
->expects($this->once())
->method('hasParameter')