From eee098c8d18abddfbc1f593db1bad49fb765c075 Mon Sep 17 00:00:00 2001
From: Nathan Gass
Date: Tue, 25 Aug 2020 14:46:45 +0200
Subject: also test positional args

---
 test/getopt.t | 13 +++++++------
 1 file 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');
-- 
cgit v1.2.3