@@ -118,6 +118,30 @@ public function visibilityProvider()
118118 ];
119119 }
120120
121+ public function testEscapesDefaultFromPhp ()
122+ {
123+ $ container = new ContainerBuilder ();
124+ $ container
125+ ->register ('to-escape ' , EscapedDefaultsFromPhpCommand::class)
126+ ->addTag ('console.command ' )
127+ ;
128+
129+ $ pass = new AddConsoleCommandPass ();
130+ $ pass ->process ($ container );
131+
132+ $ commandLoader = $ container ->getDefinition ('console.command_loader ' );
133+ $ commandLocator = $ container ->getDefinition ((string ) $ commandLoader ->getArgument (0 ));
134+
135+ $ this ->assertSame (ContainerCommandLoader::class, $ commandLoader ->getClass ());
136+ $ this ->assertSame (['%%cmd%% ' => 'to-escape ' ], $ commandLoader ->getArgument (1 ));
137+ $ this ->assertEquals ([['to-escape ' => new ServiceClosureArgument (new TypedReference ('to-escape ' , EscapedDefaultsFromPhpCommand::class))]], $ commandLocator ->getArguments ());
138+ $ this ->assertSame ([], $ container ->getParameter ('console.command.ids ' ));
139+
140+ $ command = $ container ->get ('console.command_loader ' )->get ('%%cmd%% ' );
141+
142+ $ this ->assertSame ('%cmd% ' , $ command ->getName ());
143+ }
144+
121145 public function testProcessThrowAnExceptionIfTheServiceIsAbstract ()
122146 {
123147 $ this ->expectException (\InvalidArgumentException::class);
@@ -250,3 +274,8 @@ class NamedCommand extends Command
250274{
251275 protected static $ defaultName = 'default ' ;
252276}
277+
278+ class EscapedDefaultsFromPhpCommand extends Command
279+ {
280+ protected static $ defaultName = '%cmd% ' ;
281+ }
0 commit comments