23
23
use Symfony \Component \Console \Output \OutputInterface ;
24
24
use Symfony \Component \Console \Tester \ApplicationTester ;
25
25
use Symfony \Component \DependencyInjection \ContainerBuilder ;
26
+ use Symfony \Component \DependencyInjection \ContainerInterface ;
26
27
use Symfony \Component \EventDispatcher \EventDispatcher ;
28
+ use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
29
+ use Symfony \Component \HttpKernel \Bundle \Bundle ;
30
+ use Symfony \Component \HttpKernel \Bundle \BundleInterface ;
27
31
use Symfony \Component \HttpKernel \KernelInterface ;
28
32
29
33
class ApplicationTest extends TestCase
30
34
{
31
35
public function testBundleInterfaceImplementation ()
32
36
{
33
- $ bundle = $ this ->getMockBuilder (\ Symfony \ Component \ HttpKernel \ Bundle \ BundleInterface::class)-> getMock ( );
37
+ $ bundle = $ this ->createMock ( BundleInterface::class);
34
38
35
39
$ kernel = $ this ->getKernel ([$ bundle ], true );
36
40
@@ -126,7 +130,7 @@ public function testRunOnlyWarnsOnUnregistrableCommand()
126
130
$ container ->register (ThrowingCommand::class, ThrowingCommand::class);
127
131
$ container ->setParameter ('console.command.ids ' , [ThrowingCommand::class => ThrowingCommand::class]);
128
132
129
- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
133
+ $ kernel = $ this ->createMock (KernelInterface::class);
130
134
$ kernel
131
135
->method ('getBundles ' )
132
136
->willReturn ([$ this ->createBundleMock (
@@ -154,7 +158,7 @@ public function testRegistrationErrorsAreDisplayedOnCommandNotFound()
154
158
$ container = new ContainerBuilder ();
155
159
$ container ->register ('event_dispatcher ' , EventDispatcher::class);
156
160
157
- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
161
+ $ kernel = $ this ->createMock (KernelInterface::class);
158
162
$ kernel
159
163
->method ('getBundles ' )
160
164
->willReturn ([$ this ->createBundleMock (
@@ -183,7 +187,7 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd()
183
187
$ container ->register (ThrowingCommand::class, ThrowingCommand::class);
184
188
$ container ->setParameter ('console.command.ids ' , [ThrowingCommand::class => ThrowingCommand::class]);
185
189
186
- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
190
+ $ kernel = $ this ->createMock (KernelInterface::class);
187
191
$ kernel ->expects ($ this ->once ())->method ('boot ' );
188
192
$ kernel
189
193
->method ('getBundles ' )
@@ -236,10 +240,10 @@ private function createEventForSuggestingPackages(string $command, array $altern
236
240
237
241
private function getKernel (array $ bundles , $ useDispatcher = false )
238
242
{
239
- $ container = $ this ->getMockBuilder (\ Symfony \ Component \ DependencyInjection \ ContainerInterface::class)-> getMock ( );
243
+ $ container = $ this ->createMock ( ContainerInterface::class);
240
244
241
245
if ($ useDispatcher ) {
242
- $ dispatcher = $ this ->getMockBuilder (\ Symfony \ Component \ EventDispatcher \ EventDispatcherInterface::class)-> getMock ( );
246
+ $ dispatcher = $ this ->createMock ( EventDispatcherInterface::class);
243
247
$ dispatcher
244
248
->expects ($ this ->atLeastOnce ())
245
249
->method ('dispatch ' )
@@ -264,7 +268,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
264
268
->willReturnOnConsecutiveCalls ([], [])
265
269
;
266
270
267
- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
271
+ $ kernel = $ this ->createMock (KernelInterface::class);
268
272
$ kernel ->expects ($ this ->once ())->method ('boot ' );
269
273
$ kernel
270
274
->expects ($ this ->any ())
@@ -282,7 +286,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
282
286
283
287
private function createBundleMock (array $ commands )
284
288
{
285
- $ bundle = $ this ->getMockBuilder (\ Symfony \ Component \ HttpKernel \ Bundle \Bundle ::class)-> getMock ( );
289
+ $ bundle = $ this ->createMock ( Bundle::class);
286
290
$ bundle
287
291
->expects ($ this ->once ())
288
292
->method ('registerCommands ' )
0 commit comments