Mercurial > hg > rc1
comparison vendor/pear/console_commandline/tests/console_commandline_addargument_2.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 --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 |
