@@ -296,10 +296,8 @@ public function testHasParameterOption()
296
296
$ input = new ArgvInput (array ('cli.php ' , '-f ' , 'foo ' ));
297
297
$ this ->assertTrue ($ input ->hasParameterOption ('-f ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
298
298
299
- $ input = new ArgvInput (array ('cli.php ' , '-fh ' ));
300
- $ this ->assertTrue ($ input ->hasParameterOption ('-fh ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
301
-
302
- $ input = new ArgvInput (array ('cli.php ' , '-e=test ' ));
299
+ $ input = new ArgvInput (array ('cli.php ' , '-etest ' ));
300
+ $ this ->assertTrue ($ input ->hasParameterOption ('-e ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
303
301
$ this ->assertFalse ($ input ->hasParameterOption ('-s ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
304
302
305
303
$ input = new ArgvInput (array ('cli.php ' , '--foo ' , 'foo ' ));
@@ -312,6 +310,33 @@ public function testHasParameterOption()
312
310
$ this ->assertTrue ($ input ->hasParameterOption ('--foo ' ), '->hasParameterOption() returns true if the given option with provided value is in the raw input ' );
313
311
}
314
312
313
+ public function testHasParameterOptionEdgeCasesAndLimitations ()
314
+ {
315
+ $ input = new ArgvInput (array ('cli.php ' , '-fh ' ));
316
+ // hasParameterOption does not know if the previous short option, -f,
317
+ // takes a value or not. If -f takes a value, then -fh does NOT include
318
+ // -h; Otherwise it does. Since we do not know which short options take
319
+ // values, hasParameterOption does not support this use-case.
320
+ $ this ->assertFalse ($ input ->hasParameterOption ('-h ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
321
+ // hasParameterOption does detect that `-fh` contains `-f`, since
322
+ // `-f` is the first short option in the set.
323
+ $ this ->assertTrue ($ input ->hasParameterOption ('-f ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
324
+ // The test below happens to pass, although it might make more sense
325
+ // to disallow it, and require the use of
326
+ // $input->hasParameterOption('-f') && $input->hasParameterOption('-h')
327
+ // instead.
328
+ $ this ->assertTrue ($ input ->hasParameterOption ('-fh ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
329
+ // In theory, if -fh is supported, then -hf should also work.
330
+ // However, this is not supported.
331
+ $ this ->assertFalse ($ input ->hasParameterOption ('-hf ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
332
+
333
+ $ input = new ArgvInput (array ('cli.php ' , '-f ' , '-h ' ));
334
+ // If hasParameterOption('-fh') is supported for 'cli.php -fh', then
335
+ // one might also expect that it should also be supported for
336
+ // 'cli.php -f -h'. However, this is not supported.
337
+ $ this ->assertFalse ($ input ->hasParameterOption ('-fh ' ), '->hasParameterOption() returns true if the given short option is in the raw input ' );
338
+ }
339
+
315
340
public function testToString ()
316
341
{
317
342
$ input = new ArgvInput (array ('cli.php ' , '-f ' , 'foo ' ));
@@ -333,6 +358,7 @@ public function testGetParameterOptionEqualSign($argv, $key, $expected)
333
358
public function provideGetParameterOptionValues ()
334
359
{
335
360
return array (
361
+ array (array ('app/console ' , 'foo:bar ' , '-edev ' ), '-e ' , 'dev ' ),
336
362
array (array ('app/console ' , 'foo:bar ' , '-e ' , 'dev ' ), '-e ' , 'dev ' ),
337
363
array (array ('app/console ' , 'foo:bar ' , '--env=dev ' ), '--env ' , 'dev ' ),
338
364
array (array ('app/console ' , 'foo:bar ' , '-e ' , 'dev ' ), array ('-e ' , '--env ' ), 'dev ' ),
0 commit comments