@@ -153,6 +153,33 @@ public function testProcessFallsBackToDefaultDescription()
153
153
$ this ->assertSame (1 + $ initCounter , DescribedCommand::$ initCounter );
154
154
}
155
155
156
+ public function testEscapesDefaultFromPhp ()
157
+ {
158
+ $ container = new ContainerBuilder ();
159
+ $ container
160
+ ->register ('to-escape ' , EscapedDefaultsFromPhpCommand::class)
161
+ ->addTag ('console.command ' )
162
+ ;
163
+
164
+ $ pass = new AddConsoleCommandPass ();
165
+ $ pass ->process ($ container );
166
+
167
+ $ commandLoader = $ container ->getDefinition ('console.command_loader ' );
168
+ $ commandLocator = $ container ->getDefinition ((string ) $ commandLoader ->getArgument (0 ));
169
+
170
+ $ this ->assertSame (ContainerCommandLoader::class, $ commandLoader ->getClass ());
171
+ $ this ->assertSame (['%%cmd%% ' => 'to-escape ' , '%%cmdalias%% ' => 'to-escape ' ], $ commandLoader ->getArgument (1 ));
172
+ $ this ->assertEquals ([['to-escape ' => new ServiceClosureArgument (new Reference ('.to-escape.lazy ' ))]], $ commandLocator ->getArguments ());
173
+ $ this ->assertSame ([], $ container ->getParameter ('console.command.ids ' ));
174
+
175
+ $ command = $ container ->get ('console.command_loader ' )->get ('%%cmd%% ' );
176
+
177
+ $ this ->assertInstanceOf (LazyCommand::class, $ command );
178
+ $ this ->assertSame ('%cmd% ' , $ command ->getName ());
179
+ $ this ->assertSame (['%cmdalias% ' ], $ command ->getAliases ());
180
+ $ this ->assertSame ('Creates a 80% discount ' , $ command ->getDescription ());
181
+ }
182
+
156
183
public function testProcessThrowAnExceptionIfTheServiceIsAbstract ()
157
184
{
158
185
$ this ->expectException (\InvalidArgumentException::class);
@@ -286,6 +313,12 @@ class NamedCommand extends Command
286
313
protected static $ defaultName = 'default ' ;
287
314
}
288
315
316
+ class EscapedDefaultsFromPhpCommand extends Command
317
+ {
318
+ protected static $ defaultName = '%cmd%|%cmdalias% ' ;
319
+ protected static $ defaultDescription = 'Creates a 80% discount ' ;
320
+ }
321
+
289
322
class DescribedCommand extends Command
290
323
{
291
324
public static $ initCounter = 0 ;
0 commit comments