@@ -31,28 +31,27 @@ public function testProcess($public)
31
31
$ container ->addCompilerPass (new AddConsoleCommandPass ());
32
32
$ container ->setParameter ('my-command.class ' , 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand ' );
33
33
34
+ $ id = 'my-command ' ;
34
35
$ definition = new Definition ('%my-command.class% ' );
35
36
$ definition ->setPublic ($ public );
36
37
$ definition ->addTag ('console.command ' );
37
- $ container ->setDefinition (' my-command ' , $ definition );
38
+ $ container ->setDefinition ($ id , $ definition );
38
39
39
40
$ container ->compile ();
40
41
41
- $ alias = 'console.command.symfony_component_console_tests_dependencyinjection_mycommand ' ;
42
+ $ alias = 'console.command.public_alias.my-command ' ;
42
43
43
44
if ($ public ) {
44
45
$ this ->assertFalse ($ container ->hasAlias ($ alias ));
45
- $ id = 'my-command ' ;
46
46
} else {
47
- $ id = $ alias ;
48
47
// The alias is replaced by a Definition by the ReplaceAliasByActualDefinitionPass
49
48
// in case the original service is private
50
- $ this ->assertFalse ($ container ->hasDefinition (' my-command ' ));
49
+ $ this ->assertFalse ($ container ->hasDefinition ($ id ));
51
50
$ this ->assertTrue ($ container ->hasDefinition ($ alias ));
52
51
}
53
52
54
53
$ this ->assertTrue ($ container ->hasParameter ('console.command.ids ' ));
55
- $ this ->assertSame (array ($ alias => $ id ), $ container ->getParameter ('console.command.ids ' ));
54
+ $ this ->assertSame (array ($ public ? $ id : $ alias ), $ container ->getParameter ('console.command.ids ' ));
56
55
}
57
56
58
57
public function testProcessRegistersLazyCommands ()
@@ -73,8 +72,7 @@ public function testProcessRegistersLazyCommands()
73
72
$ this ->assertSame (ContainerCommandLoader::class, $ commandLoader ->getClass ());
74
73
$ this ->assertSame (array ('my:command ' => 'my-command ' , 'my:alias ' => 'my-command ' ), $ commandLoader ->getArgument (1 ));
75
74
$ this ->assertEquals (array (array ('my-command ' => new ServiceClosureArgument (new TypedReference ('my-command ' , MyCommand::class)))), $ commandLocator ->getArguments ());
76
- $ this ->assertSame (array ('console.command.symfony_component_console_tests_dependencyinjection_mycommand ' => 'my-command ' ), $ container ->getParameter ('console.command.ids ' ));
77
- $ this ->assertSame (array ('my-command ' => true ), $ container ->getParameter ('console.lazy_command.ids ' ));
75
+ $ this ->assertSame (array (), $ container ->getParameter ('console.command.ids ' ));
78
76
$ this ->assertSame (array (array ('setName ' , array ('my:command ' )), array ('setAliases ' , array (array ('my:alias ' )))), $ command ->getMethodCalls ());
79
77
}
80
78
@@ -96,8 +94,7 @@ public function testProcessFallsBackToDefaultName()
96
94
$ this ->assertSame (ContainerCommandLoader::class, $ commandLoader ->getClass ());
97
95
$ this ->assertSame (array ('default ' => 'with-default-name ' ), $ commandLoader ->getArgument (1 ));
98
96
$ this ->assertEquals (array (array ('with-default-name ' => new ServiceClosureArgument (new TypedReference ('with-default-name ' , NamedCommand::class)))), $ commandLocator ->getArguments ());
99
- $ this ->assertSame (array ('console.command.symfony_component_console_tests_dependencyinjection_namedcommand ' => 'with-default-name ' ), $ container ->getParameter ('console.command.ids ' ));
100
- $ this ->assertSame (array ('with-default-name ' => true ), $ container ->getParameter ('console.lazy_command.ids ' ));
97
+ $ this ->assertSame (array (), $ container ->getParameter ('console.command.ids ' ));
101
98
102
99
$ container = new ContainerBuilder ();
103
100
$ container
@@ -170,10 +167,9 @@ public function testProcessPrivateServicesWithSameCommand()
170
167
171
168
(new AddConsoleCommandPass ())->process ($ container );
172
169
173
- $ alias1 = 'console.command.symfony_component_console_tests_dependencyinjection_mycommand ' ;
174
- $ alias2 = $ alias1 .'_my-command2 ' ;
175
- $ this ->assertTrue ($ container ->hasAlias ($ alias1 ));
176
- $ this ->assertTrue ($ container ->hasAlias ($ alias2 ));
170
+ $ aliasPrefix = 'console.command.public_alias. ' ;
171
+ $ this ->assertTrue ($ container ->hasAlias ($ aliasPrefix .'my-command1 ' ));
172
+ $ this ->assertTrue ($ container ->hasAlias ($ aliasPrefix .'my-command2 ' ));
177
173
}
178
174
}
179
175
0 commit comments