Mercurial > hg > rc1
comparison vendor/pear/console_commandline/tests/console_commandline_addargument.phpt @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e000243b222 |
---|---|
1 --TEST-- | |
2 Test for Console_CommandLine::addArgument() method. | |
3 --FILE-- | |
4 <?php | |
5 | |
6 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tests.inc.php'; | |
7 | |
8 $parser = new Console_CommandLine(); | |
9 $parser->addArgument('arg1'); | |
10 $parser->addArgument('arg2', array( | |
11 'multiple' => true, | |
12 'description' => 'description of arg2' | |
13 )); | |
14 $arg3 = new Console_CommandLine_Argument('arg3', array( | |
15 'multiple' => true, | |
16 'description' => 'description of arg3' | |
17 )); | |
18 $parser->addArgument($arg3); | |
19 $parser->addArgument('arg4', array('optional' => true)); | |
20 | |
21 var_dump($parser->args); | |
22 | |
23 // a bad argument | |
24 $parser->addArgument('Some invalid name'); | |
25 | |
26 ?> | |
27 --EXPECTF-- | |
28 array(4) { | |
29 ["arg1"]=> | |
30 object(Console_CommandLine_Argument)#%d (8) { | |
31 ["multiple"]=> | |
32 bool(false) | |
33 ["optional"]=> | |
34 bool(false) | |
35 ["choices"]=> | |
36 array(0) { | |
37 } | |
38 ["name"]=> | |
39 string(4) "arg1" | |
40 ["help_name"]=> | |
41 string(4) "arg1" | |
42 ["description"]=> | |
43 NULL | |
44 ["default"]=> | |
45 NULL | |
46 ["messages"]=> | |
47 array(0) { | |
48 } | |
49 } | |
50 ["arg2"]=> | |
51 object(Console_CommandLine_Argument)#%d (8) { | |
52 ["multiple"]=> | |
53 bool(true) | |
54 ["optional"]=> | |
55 bool(false) | |
56 ["choices"]=> | |
57 array(0) { | |
58 } | |
59 ["name"]=> | |
60 string(4) "arg2" | |
61 ["help_name"]=> | |
62 string(4) "arg2" | |
63 ["description"]=> | |
64 string(19) "description of arg2" | |
65 ["default"]=> | |
66 NULL | |
67 ["messages"]=> | |
68 array(0) { | |
69 } | |
70 } | |
71 ["arg3"]=> | |
72 object(Console_CommandLine_Argument)#%d (8) { | |
73 ["multiple"]=> | |
74 bool(true) | |
75 ["optional"]=> | |
76 bool(false) | |
77 ["choices"]=> | |
78 array(0) { | |
79 } | |
80 ["name"]=> | |
81 string(4) "arg3" | |
82 ["help_name"]=> | |
83 string(4) "arg3" | |
84 ["description"]=> | |
85 string(19) "description of arg3" | |
86 ["default"]=> | |
87 NULL | |
88 ["messages"]=> | |
89 array(0) { | |
90 } | |
91 } | |
92 ["arg4"]=> | |
93 object(Console_CommandLine_Argument)#%d (8) { | |
94 ["multiple"]=> | |
95 bool(false) | |
96 ["optional"]=> | |
97 bool(true) | |
98 ["choices"]=> | |
99 array(0) { | |
100 } | |
101 ["name"]=> | |
102 string(4) "arg4" | |
103 ["help_name"]=> | |
104 string(4) "arg4" | |
105 ["description"]=> | |
106 NULL | |
107 ["default"]=> | |
108 NULL | |
109 ["messages"]=> | |
110 array(0) { | |
111 } | |
112 } | |
113 } | |
114 | |
115 Fatal error: argument name must be a valid php variable name (got: Some invalid name) in %sCommandLine.php on line %d |