0
|
1 --TEST--
|
|
2 Test for Console_CommandLine::parse() method (user argc/argv 2).
|
|
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', '-v', 'install', '-f', 'foo');
|
|
11 $argc = count($argv);
|
|
12 try {
|
|
13 $parser = buildParser2();
|
|
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(4) {
|
|
25 ["verbose"]=>
|
|
26 bool(true)
|
|
27 ["logfile"]=>
|
|
28 NULL
|
|
29 ["help"]=>
|
|
30 NULL
|
|
31 ["version"]=>
|
|
32 NULL
|
|
33 }
|
|
34 ["args"]=>
|
|
35 array(0) {
|
|
36 }
|
|
37 ["command_name"]=>
|
|
38 string(7) "install"
|
|
39 ["command"]=>
|
|
40 object(Console_CommandLine_Result)#%d (4) {
|
|
41 ["options"]=>
|
|
42 array(2) {
|
|
43 ["force"]=>
|
|
44 bool(true)
|
|
45 ["help"]=>
|
|
46 NULL
|
|
47 }
|
|
48 ["args"]=>
|
|
49 array(1) {
|
|
50 ["package"]=>
|
|
51 string(3) "foo"
|
|
52 }
|
|
53 ["command_name"]=>
|
|
54 bool(false)
|
|
55 ["command"]=>
|
|
56 bool(false)
|
|
57 }
|
|
58 }
|