Skip to content

Commit ce6e5ac

Browse files
committed
[2.7] [FrameworkBundle] minor fix tests added by #17569
1 parent 653428a commit ce6e5ac

File tree

1 file changed

+22
-40
lines changed

1 file changed

+22
-40
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php

+22-40
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testBundleInterfaceImplementation()
2424
{
2525
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
2626

27-
$kernel = $this->getKernel(array($bundle));
27+
$kernel = $this->getKernel(array($bundle), true);
2828

2929
$application = new Application($kernel);
3030
$application->doRun(new ArrayInput(array('list')), new NullOutput());
@@ -35,7 +35,7 @@ public function testBundleCommandsAreRegistered()
3535
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
3636
$bundle->expects($this->once())->method('registerCommands');
3737

38-
$kernel = $this->getKernel(array($bundle));
38+
$kernel = $this->getKernel(array($bundle), true);
3939

4040
$application = new Application($kernel);
4141
$application->doRun(new ArrayInput(array('list')), new NullOutput());
@@ -49,12 +49,7 @@ public function testBundleCommandsAreRetrievable()
4949
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
5050
$bundle->expects($this->once())->method('registerCommands');
5151

52-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
53-
$kernel
54-
->expects($this->any())
55-
->method('getBundles')
56-
->will($this->returnValue(array($bundle)))
57-
;
52+
$kernel = $this->getKernel(array($bundle));
5853

5954
$application = new Application($kernel);
6055
$application->all();
@@ -68,12 +63,7 @@ public function testBundleSingleCommandIsRetrievable()
6863
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
6964
$bundle->expects($this->once())->method('registerCommands');
7065

71-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
72-
$kernel
73-
->expects($this->any())
74-
->method('getBundles')
75-
->will($this->returnValue(array($bundle)))
76-
;
66+
$kernel = $this->getKernel(array($bundle));
7767

7868
$application = new Application($kernel);
7969

@@ -88,12 +78,7 @@ public function testBundleCommandCanBeFound()
8878
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
8979
$bundle->expects($this->once())->method('registerCommands');
9080

91-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
92-
$kernel
93-
->expects($this->any())
94-
->method('getBundles')
95-
->will($this->returnValue(array($bundle)))
96-
;
81+
$kernel = $this->getKernel(array($bundle));
9782

9883
$application = new Application($kernel);
9984

@@ -108,12 +93,7 @@ public function testBundleCommandCanBeFoundByAlias()
10893
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
10994
$bundle->expects($this->once())->method('registerCommands');
11095

111-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
112-
$kernel
113-
->expects($this->any())
114-
->method('getBundles')
115-
->will($this->returnValue(array($bundle)))
116-
;
96+
$kernel = $this->getKernel(array($bundle));
11797

11898
$application = new Application($kernel);
11999

@@ -130,7 +110,7 @@ public function testBundleCommandsHaveRightContainer()
130110
$command->setCode(function () {});
131111
$command->expects($this->exactly(2))->method('setContainer');
132112

133-
$application = new Application($this->getKernel(array()));
113+
$application = new Application($this->getKernel(array(), true));
134114
$application->setAutoExit(false);
135115
$application->setCatchExceptions(false);
136116
$application->add($command);
@@ -143,21 +123,23 @@ public function testBundleCommandsHaveRightContainer()
143123
$tester->run(array('command' => 'foo'));
144124
}
145125

146-
private function getKernel(array $bundles)
126+
private function getKernel(array $bundles, $useDispatcher = false)
147127
{
148-
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
149-
$dispatcher
150-
->expects($this->atLeastOnce())
151-
->method('dispatch')
152-
;
153-
154128
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
155-
$container
156-
->expects($this->atLeastOnce())
157-
->method('get')
158-
->with($this->equalTo('event_dispatcher'))
159-
->will($this->returnValue($dispatcher))
160-
;
129+
130+
if ($useDispatcher) {
131+
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
132+
$dispatcher
133+
->expects($this->atLeastOnce())
134+
->method('dispatch')
135+
;
136+
$container
137+
->expects($this->atLeastOnce())
138+
->method('get')
139+
->with($this->equalTo('event_dispatcher'))
140+
->will($this->returnValue($dispatcher));
141+
}
142+
161143
$container
162144
->expects($this->once())
163145
->method('hasParameter')

0 commit comments

Comments
 (0)