1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/www/server/bin/php -qC
<?php
# Tests for getopt in it.class
require 'searchlib/search_test.class';
$usage = "Usage: doesnotexist.php [OPTIONS]
Some help to a not existing program
-h,--help the help argument
-a,--argument=ARG the arg argument
";
function getopt_ok($argv, $exp, $name)
{
$_SERVER['argv'] = array_merge(array('doesnotexist.php'), $argv);
$got = it::getopt($GLOBALS['usage']);
return is($got['argument'], $exp, $name);
}
$testarg = "blah gnaber";
getopt_ok(array('-a', $testarg), $testarg, "Short version");
getopt_ok(array('--argument', $testarg), $testarg, "Long version with space");
getopt_ok(array("--argument=$testarg"), $testarg, "Long version with equal");
|