@@ -14,7 +14,9 @@ use Nette\DI\ServiceCreationException;
1414use Symfony \Component \Console \Command \Command ;
1515use Tester \Assert ;
1616use Tester \FileMock ;
17+ use Tests \Fixtures \FooAliasCommand ;
1718use Tests \Fixtures \FooCommand ;
19+ use Tests \Fixtures \FooHiddenCommand ;
1820use Tests \Fixtures \FooRequestFactory ;
1921
2022require_once __DIR__ . '/../../bootstrap.php ' ;
@@ -246,3 +248,49 @@ Toolkit::test(function (): void {
246248 new $ class ();
247249 }, ServiceCreationException::class, 'Custom http.requestFactory is used, argument console.url should be removed. ' );
248250});
251+
252+ // 1 command with aliases
253+ Toolkit::test (function (): void {
254+ $ loader = new ContainerLoader (Environment::getTestDir (), true );
255+ $ class = $ loader ->load (function (Compiler $ compiler ): void {
256+ $ compiler ->addExtension ('console ' , new ConsoleExtension (true ));
257+ $ compiler ->loadConfig (FileMock::create ('
258+ console:
259+ services:
260+ foo: Tests\Fixtures\FooAliasCommand
261+ ' , 'neon ' ));
262+ }, [getmypid (), 13 ]);
263+
264+ /** @var Container $container */
265+ $ container = new $ class ();
266+
267+ $ application = $ container ->getByType (Application::class);
268+ Assert::type (Application::class, $ application );
269+ Assert::false ($ container ->isCreated ('foo ' ));
270+ Assert::count (1 , $ container ->findByType (Command::class));
271+ Assert::type (FooAliasCommand::class, $ container ->getByType (Command::class));
272+ $ application ->all ();
273+ });
274+
275+ // 1 hidden command
276+ Toolkit::test (function (): void {
277+ $ loader = new ContainerLoader (Environment::getTestDir (), true );
278+ $ class = $ loader ->load (function (Compiler $ compiler ): void {
279+ $ compiler ->addExtension ('console ' , new ConsoleExtension (true ));
280+ $ compiler ->loadConfig (FileMock::create ('
281+ console:
282+ services:
283+ foo: Tests\Fixtures\FooHiddenCommand
284+ ' , 'neon ' ));
285+ }, [getmypid (), 14 ]);
286+
287+ /** @var Container $container */
288+ $ container = new $ class ();
289+
290+ $ application = $ container ->getByType (Application::class);
291+ Assert::type (Application::class, $ application );
292+ Assert::false ($ container ->isCreated ('foo ' ));
293+ Assert::count (1 , $ container ->findByType (Command::class));
294+ Assert::type (FooHiddenCommand::class, $ container ->getByType (Command::class));
295+ $ application ->all ();
296+ });
0 commit comments