@@ -309,21 +309,23 @@ public function testSuccessMessageGoesToStdout()
309309$ receiver =$ this ->createMock (ReceiverInterface::class);
310310$ receiver ->expects ($ this ->once ())->method ('get ' )->willReturn ([$ envelope ]);
311311
312- $ receiverLocator =$ this ->createMock (ContainerInterface::class);
313- $ receiverLocator ->expects ($ this ->once ())->method ('has ' )->with ('dummy-receiver ' )->willReturn (true );
314- $ receiverLocator ->expects ($ this ->once ())->method ('get ' )->with ('dummy-receiver ' )->willReturn ($ receiver );
312+ $ receiverLocator =new Container ();
313+ $ receiverLocator ->set ('dummy-receiver ' ,$ receiver );
315314
316315$ bus =$ this ->createMock (MessageBusInterface::class);
317316$ bus ->expects ($ this ->once ())->method ('dispatch ' );
318317
319- $ busLocator =$ this ->createMock (ContainerInterface::class);
320- $ busLocator ->expects ($ this ->once ())->method ('has ' )->with ('dummy-bus ' )->willReturn (true );
321- $ busLocator ->expects ($ this ->once ())->method ('get ' )->with ('dummy-bus ' )->willReturn ($ bus );
318+ $ busLocator =new Container ();
319+ $ busLocator ->set ('dummy-bus ' ,$ bus );
322320
323321$ command =new ConsumeMessagesCommand (new RoutableMessageBus ($ busLocator ),$ receiverLocator ,new EventDispatcher ());
324322
325323$ application =new Application ();
326- $ application ->add ($ command );
324+ if (method_exists ($ application ,'addCommand ' )) {
325+ $ application ->addCommand ($ command );
326+ }else {
327+ $ application ->add ($ command );
328+ }
327329$ tester =new CommandTester ($ application ->get ('messenger:consume ' ));
328330$ tester ->execute ([
329331'receivers ' => ['dummy-receiver ' ],
@@ -344,21 +346,23 @@ public function testCommentsGoToStderr()
344346$ receiver =$ this ->createMock (ReceiverInterface::class);
345347$ receiver ->expects ($ this ->once ())->method ('get ' )->willReturn ([$ envelope ]);
346348
347- $ receiverLocator =$ this ->createMock (ContainerInterface::class);
348- $ receiverLocator ->expects ($ this ->once ())->method ('has ' )->with ('dummy-receiver ' )->willReturn (true );
349- $ receiverLocator ->expects ($ this ->once ())->method ('get ' )->with ('dummy-receiver ' )->willReturn ($ receiver );
349+ $ receiverLocator =new Container ();
350+ $ receiverLocator ->set ('dummy-receiver ' ,$ receiver );
350351
351352$ bus =$ this ->createMock (MessageBusInterface::class);
352353$ bus ->expects ($ this ->once ())->method ('dispatch ' );
353354
354- $ busLocator =$ this ->createMock (ContainerInterface::class);
355- $ busLocator ->expects ($ this ->once ())->method ('has ' )->with ('dummy-bus ' )->willReturn (true );
356- $ busLocator ->expects ($ this ->once ())->method ('get ' )->with ('dummy-bus ' )->willReturn ($ bus );
355+ $ busLocator =new Container ();
356+ $ busLocator ->set ('dummy-bus ' ,$ bus );
357357
358358$ command =new ConsumeMessagesCommand (new RoutableMessageBus ($ busLocator ),$ receiverLocator ,new EventDispatcher ());
359359
360360$ application =new Application ();
361- $ application ->add ($ command );
361+ if (method_exists ($ application ,'addCommand ' )) {
362+ $ application ->addCommand ($ command );
363+ }else {
364+ $ application ->add ($ command );
365+ }
362366$ tester =new CommandTester ($ application ->get ('messenger:consume ' ));
363367$ tester ->execute ([
364368'receivers ' => ['dummy-receiver ' ],