diff options
| author | Nathan Gass | 2020-08-25 14:46:45 +0200 | 
|---|---|---|
| committer | Nathan Gass | 2020-08-25 14:46:45 +0200 | 
| commit | eee098c8d18abddfbc1f593db1bad49fb765c075 (patch) | |
| tree | 6eccf0248fbfa2bde0e488f2a4b51f5219afa4a3 | |
| parent | 110004fb47cdff77cc3aeb35c80279a27fdfa7d0 (diff) | |
| download | itools-eee098c8d18abddfbc1f593db1bad49fb765c075.tar.gz itools-eee098c8d18abddfbc1f593db1bad49fb765c075.tar.bz2 itools-eee098c8d18abddfbc1f593db1bad49fb765c075.zip  | |
also test positional args
| -rwxr-xr-x | test/getopt.t | 13 | 
1 files changed, 7 insertions, 6 deletions
diff --git a/test/getopt.t b/test/getopt.t index cf3d9e8..87f7550 100755 --- a/test/getopt.t +++ b/test/getopt.t @@ -3,7 +3,7 @@  # Tests for getopt in it.class -$GLOBALS['usage'] = "Usage: doesnotexist.php [OPTIONS] +$GLOBALS['usage'] = "Usage: doesnotexist.php [OPTIONS] POSITIONAL  	Some help to a not existing program  	  -h,--help          the help argument  	  -a,--argument=ARG  the arg argument @@ -14,15 +14,16 @@ function getopt_ok($argv, $exp, $name)  {  	$_SERVER['argv'] = array_merge(['doesnotexist.php'], $argv);  	$got = it::getopt($GLOBALS['usage']); -	return is($got['argument'], $exp, $name); +	return is($got, $exp, $name);  }  foreach (["" => "blah gnaber", " (umlaute)" => "pre üäpost"] as $variant => $testarg) { -	getopt_ok(['-a', $testarg], $testarg, "Short version" . $variant); -	getopt_ok(['--argument', $testarg], $testarg, "Long version with space" . $variant); -	getopt_ok(["--argument=$testarg"], $testarg, "Long version with equal" . $variant); +	$exp = ['args' => [], 'positional' => $testarg, 'argument' => $testarg]; +	getopt_ok([$testarg, '-a', $testarg], $exp, "Short version" . $variant); +	getopt_ok([$testarg, '--argument', $testarg], $exp, "Long version with space" . $variant); +	getopt_ok([$testarg, "--argument=$testarg"], $exp, "Long version with equal" . $variant);  } -$_SERVER['argv'] = ['doesnotexist.php', '-0']; +$_SERVER['argv'] = ['doesnotexist.php', 'posarg', '-0'];  $zero_opts = it::getopt($GLOBALS['usage']);  ok($zero_opts['zero'], '-0');  |