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