@@ -192,6 +192,34 @@ public function testRegistrationErrorsAreDisplayedOnCommandNotFound()
192
192
$ this ->assertContains ('Command "fine" is not defined. ' , $ output );
193
193
}
194
194
195
+ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd ()
196
+ {
197
+ $ container = new ContainerBuilder ();
198
+ $ container ->register ('event_dispatcher ' , EventDispatcher::class);
199
+ $ container ->register (ThrowingCommand::class, ThrowingCommand::class);
200
+ $ container ->setParameter ('console.command.ids ' , array (ThrowingCommand::class => ThrowingCommand::class));
201
+
202
+ $ kernel = $ this ->getMockBuilder (KernelInterface::class)->getMock ();
203
+ $ kernel
204
+ ->method ('getBundles ' )
205
+ ->willReturn (array ($ this ->createBundleMock (
206
+ array ((new Command ('fine ' ))->setCode (function (InputInterface $ input , OutputInterface $ output ) { $ output ->write ('fine ' ); }))
207
+ )));
208
+ $ kernel
209
+ ->method ('getContainer ' )
210
+ ->willReturn ($ container );
211
+
212
+ $ application = new Application ($ kernel );
213
+ $ application ->setAutoExit (false );
214
+
215
+ $ tester = new ApplicationTester ($ application );
216
+ $ tester ->run (array ('command ' => 'list ' ));
217
+
218
+ $ this ->assertSame (0 , $ tester ->getStatusCode ());
219
+ $ display = explode ('Lists commands ' , $ tester ->getDisplay ());
220
+ $ this ->assertContains (trim ('[WARNING] Some commands could not be registered: ' ), trim ($ display [1 ]));
221
+ }
222
+
195
223
private function getKernel (array $ bundles , $ useDispatcher = false )
196
224
{
197
225
$ container = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ContainerInterface ' )->getMock ();
0 commit comments