summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/getopt.t13
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');