2323use Symfony \Component \Console \Output \OutputInterface ;
2424use Symfony \Component \Console \Tester \ApplicationTester ;
2525use Symfony \Component \DependencyInjection \ContainerBuilder ;
26+ use Symfony \Component \DependencyInjection \ContainerInterface ;
2627use Symfony \Component \EventDispatcher \EventDispatcher ;
28+ use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
29+ use Symfony \Component \HttpKernel \Bundle \Bundle ;
30+ use Symfony \Component \HttpKernel \Bundle \BundleInterface ;
2731use Symfony \Component \HttpKernel \KernelInterface ;
2832
2933class ApplicationTest extends TestCase
3034{
3135 public function testBundleInterfaceImplementation ()
3236 {
33- $ bundle = $ this ->getMockBuilder (\ Symfony \ Component \ HttpKernel \ Bundle \ BundleInterface::class)-> getMock ( );
37+ $ bundle = $ this ->createMock ( BundleInterface::class);
3438
3539 $ kernel = $ this ->getKernel ([$ bundle ], true );
3640
@@ -126,7 +130,7 @@ public function testRunOnlyWarnsOnUnregistrableCommand()
126130 $ container ->register (ThrowingCommand::class, ThrowingCommand::class);
127131 $ container ->setParameter ('console.command.ids ' , [ThrowingCommand::class => ThrowingCommand::class]);
128132
129- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
133+ $ kernel = $ this ->createMock (KernelInterface::class);
130134 $ kernel
131135 ->method ('getBundles ' )
132136 ->willReturn ([$ this ->createBundleMock (
@@ -154,7 +158,7 @@ public function testRegistrationErrorsAreDisplayedOnCommandNotFound()
154158 $ container = new ContainerBuilder ();
155159 $ container ->register ('event_dispatcher ' , EventDispatcher::class);
156160
157- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
161+ $ kernel = $ this ->createMock (KernelInterface::class);
158162 $ kernel
159163 ->method ('getBundles ' )
160164 ->willReturn ([$ this ->createBundleMock (
@@ -183,7 +187,7 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd()
183187 $ container ->register (ThrowingCommand::class, ThrowingCommand::class);
184188 $ container ->setParameter ('console.command.ids ' , [ThrowingCommand::class => ThrowingCommand::class]);
185189
186- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
190+ $ kernel = $ this ->createMock (KernelInterface::class);
187191 $ kernel ->expects ($ this ->once ())->method ('boot ' );
188192 $ kernel
189193 ->method ('getBundles ' )
@@ -236,10 +240,10 @@ private function createEventForSuggestingPackages(string $command, array $altern
236240
237241 private function getKernel (array $ bundles , $ useDispatcher = false )
238242 {
239- $ container = $ this ->getMockBuilder (\ Symfony \ Component \ DependencyInjection \ ContainerInterface::class)-> getMock ( );
243+ $ container = $ this ->createMock ( ContainerInterface::class);
240244
241245 if ($ useDispatcher ) {
242- $ dispatcher = $ this ->getMockBuilder (\ Symfony \ Component \ EventDispatcher \ EventDispatcherInterface::class)-> getMock ( );
246+ $ dispatcher = $ this ->createMock ( EventDispatcherInterface::class);
243247 $ dispatcher
244248 ->expects ($ this ->atLeastOnce ())
245249 ->method ('dispatch ' )
@@ -264,7 +268,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
264268 ->willReturnOnConsecutiveCalls ([], [])
265269 ;
266270
267- $ kernel = $ this ->getMockBuilder (KernelInterface::class)-> getMock ( );
271+ $ kernel = $ this ->createMock (KernelInterface::class);
268272 $ kernel ->expects ($ this ->once ())->method ('boot ' );
269273 $ kernel
270274 ->expects ($ this ->any ())
@@ -282,7 +286,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
282286
283287 private function createBundleMock (array $ commands )
284288 {
285- $ bundle = $ this ->getMockBuilder (\ Symfony \ Component \ HttpKernel \ Bundle \Bundle ::class)-> getMock ( );
289+ $ bundle = $ this ->createMock ( Bundle::class);
286290 $ bundle
287291 ->expects ($ this ->once ())
288292 ->method ('registerCommands ' )
0 commit comments