0
|
1 --TEST--
|
|
2 Test for Console_CommandLine::addArgument() method.
|
|
3 --SKIPIF--
|
|
4 <?php if(php_sapi_name()!='cli') echo 'skip'; ?>
|
|
5 --ARGS--
|
|
6 foo
|
|
7 --FILE--
|
|
8 <?php
|
|
9
|
|
10 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tests.inc.php';
|
|
11
|
|
12 $parser = new Console_CommandLine();
|
|
13 $parser->addArgument('arg1');
|
|
14 $parser->addArgument('arg2', array(
|
|
15 'optional' => true,
|
|
16 'default' => 'bar'
|
|
17 ));
|
|
18
|
|
19 $result = $parser->parse();
|
|
20 echo $result->args['arg1'] . ' ' . $result->args['arg2'];
|
|
21
|
|
22 // a bad argument
|
|
23 $parser->addArgument('arg3', array('default' => 'baz'));
|
|
24
|
|
25 ?>
|
|
26 --EXPECTF--
|
|
27 foo bar
|
|
28 Fatal error: only optional arguments can have a default value in %sCommandLine.php on line %d
|