[Console] fix registering command aliases when using the new "cmd|alias" syntax for names

This commit is contained in:
Nicolas Grekas 2021-05-13 11:45:23 +02:00
parent aea15bc04f
commit 6633b95597
2 changed files with 5 additions and 1 deletions

View File

@ -94,6 +94,10 @@ class AddConsoleCommandPass implements CompilerPassInterface
$lazyCommandMap[$commandName] = $id;
$lazyCommandRefs[$id] = new TypedReference($id, $class);
foreach ($aliases as $alias) {
$lazyCommandMap[$alias] = $id;
}
foreach ($tags as $tag) {
if (isset($tag['command'])) {
$aliases[] = $tag['command'];

View File

@ -135,7 +135,7 @@ class AddConsoleCommandPassTest extends TestCase
$commandLocator = $container->getDefinition((string) $commandLoader->getArgument(0));
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
$this->assertSame(['cmdname' => 'with-defaults'], $commandLoader->getArgument(1));
$this->assertSame(['cmdname' => 'with-defaults', 'cmdalias' => 'with-defaults'], $commandLoader->getArgument(1));
$this->assertEquals([['with-defaults' => new ServiceClosureArgument(new Reference('.with-defaults.lazy'))]], $commandLocator->getArguments());
$this->assertSame([], $container->getParameter('console.command.ids'));