0
|
1 --TEST--
|
|
2 Test for Console_CommandLine::parse() method (user argc/argv 1).
|
|
3 --SKIPIF--
|
|
4 <?php if(php_sapi_name()!='cli') echo 'skip'; ?>
|
|
5 --FILE--
|
|
6 <?php
|
|
7
|
|
8 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tests.inc.php';
|
|
9
|
|
10 $argv = array('somename', '-t', '-f', '--float=1.2', 'foo', 'bar');
|
|
11 $argc = count($argv);
|
|
12 try {
|
|
13 $parser = buildParser1();
|
|
14 $result = $parser->parse($argc, $argv);
|
|
15 var_dump($result);
|
|
16 } catch (Console_CommandLine_Exception $exc) {
|
|
17 $parser->displayError($exc->getMessage());
|
|
18 }
|
|
19
|
|
20 ?>
|
|
21 --EXPECTF--
|
|
22 object(Console_CommandLine_Result)#%d (4) {
|
|
23 ["options"]=>
|
|
24 array(11) {
|
|
25 ["true"]=>
|
|
26 bool(true)
|
|
27 ["false"]=>
|
|
28 bool(false)
|
|
29 ["int"]=>
|
|
30 int(1)
|
|
31 ["float"]=>
|
|
32 float(1.2)
|
|
33 ["string"]=>
|
|
34 NULL
|
|
35 ["counter"]=>
|
|
36 NULL
|
|
37 ["callback"]=>
|
|
38 NULL
|
|
39 ["array"]=>
|
|
40 array(2) {
|
|
41 [0]=>
|
|
42 string(4) "spam"
|
|
43 [1]=>
|
|
44 string(3) "egg"
|
|
45 }
|
|
46 ["password"]=>
|
|
47 NULL
|
|
48 ["help"]=>
|
|
49 NULL
|
|
50 ["version"]=>
|
|
51 NULL
|
|
52 }
|
|
53 ["args"]=>
|
|
54 array(2) {
|
|
55 ["simple"]=>
|
|
56 string(3) "foo"
|
|
57 ["multiple"]=>
|
|
58 array(1) {
|
|
59 [0]=>
|
|
60 string(3) "bar"
|
|
61 }
|
|
62 }
|
|
63 ["command_name"]=>
|
|
64 bool(false)
|
|
65 ["command"]=>
|
|
66 bool(false)
|
|
67 }
|