This PR was merged into the 2.7 branch.
Discussion
----------
[2.7] [FrameworkBundle] minor fix tests added by #17569
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | -
Commits
-------
ce6e5ac
[2.7] [FrameworkBundle] minor fix tests added by #17569
This commit is contained in:
commit
98a946a481
@ -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')
|
||||
|
Reference in New Issue
Block a user