/**
  * test setting the console description
  *
  * @return void
  */
 public function testDescription()
 {
     $parser = new ConsoleOptionParser('test', FALSE);
     $result = $parser->description('A test');
     $this->assertEquals($parser, $result, 'Setting description is not chainable');
     $this->assertEquals('A test', $parser->description(), 'getting value is wrong.');
     $parser->description(array('A test', 'something'));
     $this->assertEquals("A test\nsomething", $parser->description(), 'getting value is wrong.');
 }
Ejemplo n.º 2
0
 public function getOptionParser()
 {
     $parser = new ConsoleOptionParser($this->name);
     $parser->description(__('RADIUSdesk console for various tasks'));
     $parser->addOption('ping', array('help' => 'Do a ping monitor test', 'boolean' => true));
     $parser->addOption('heartbeat', array('help' => 'Do a heartbeat monitor test', 'boolean' => true));
     $parser->addArgument('action', array('help' => 'The action to do', 'required' => true, 'choices' => array('mon', 'restart_check', 'debug_check', 'auto_close')));
     $parser->epilog('Have alot of fun....');
     return $parser;
 }
    /**
     * test description and epilog in the help
     *
     * @return void
     */
    public function testXmlHelpDescriptionAndEpilog()
    {
        $parser = new ConsoleOptionParser('mycommand', false);
        $parser->description('Description text')->epilog('epilog text')->addOption('test', array('help' => 'A test option.'))->addArgument('model', array('help' => 'The model to make.', 'required' => true));
        $formatter = new HelpFormatter($parser);
        $result = $formatter->xml();
        $expected = <<<TEXT
<?xml version="1.0"?>
<shell>
<name>mycommand</name>
<description>Description text</description>
<subcommands />
<options>
\t<option name="--help" short="-h" help="Display this help." boolean="1">
\t\t<default></default>
\t\t<choices></choices>
\t</option>
\t<option name="--test" short="" help="A test option." boolean="0">
\t\t<default></default>
\t\t<choices></choices>
\t</option>
</options>
<arguments>
\t<argument name="model" help="The model to make." required="1">
\t\t<choices></choices>
\t</argument>
</arguments>
<epilog>epilog text</epilog>
</shell>
TEXT;
        $this->assertEquals(new DomDocument($expected), new DomDocument($result), 'Help does not match');
    }
Ejemplo n.º 4
0
 /**
  * Build a parser from an array. Uses an array like
  *
  * {{{
  * $spec = array(
  *		'description' => 'text',
  *		'epilog' => 'text',
  *		'arguments' => array(
  *			// list of arguments compatible with addArguments.
  *		),
  *		'options' => array(
  *			// list of options compatible with addOptions
  *		),
  *		'subcommands' => array(
  *			// list of subcommands to add.
  *		)
  * );
  * }}}
  *
  * @param array $spec The spec to build the OptionParser with.
  * @return ConsoleOptionParser
  */
 public static function buildFromArray($spec)
 {
     $parser = new ConsoleOptionParser($spec['command']);
     if (!empty($spec['arguments'])) {
         $parser->addArguments($spec['arguments']);
     }
     if (!empty($spec['options'])) {
         $parser->addOptions($spec['options']);
     }
     if (!empty($spec['subcommands'])) {
         $parser->addSubcommands($spec['subcommands']);
     }
     if (!empty($spec['description'])) {
         $parser->description($spec['description']);
     }
     if (!empty($spec['epilog'])) {
         $parser->epilog($spec['epilog']);
     }
     return $parser;
 }
Ejemplo n.º 5
0
 /**
  * Gets the option parser instance and configures it.
  *
  * @return ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = new ConsoleOptionParser($this->name);
     $parser->description(__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'))->addArgument('category', array('help' => __d('cake_console', 'The category for the test, or test file, to test.'), 'required' => false))->addArgument('file', array('help' => __d('cake_console', 'The path to the file, or test file, to test.'), 'required' => false))->addOption('log-junit', array('help' => __d('cake_console', '<file> Log test execution in JUnit XML format to file.'), 'default' => false))->addOption('log-json', array('help' => __d('cake_console', '<file> Log test execution in JSON format to file.'), 'default' => false))->addOption('log-tap', array('help' => __d('cake_console', '<file> Log test execution in TAP format to file.'), 'default' => false))->addOption('log-dbus', array('help' => __d('cake_console', 'Log test execution to DBUS.'), 'default' => false))->addOption('coverage-html', array('help' => __d('cake_console', '<dir> Generate code coverage report in HTML format.'), 'default' => false))->addOption('coverage-clover', array('help' => __d('cake_console', '<file> Write code coverage data in Clover XML format.'), 'default' => false))->addOption('testdox-html', array('help' => __d('cake_console', '<file> Write agile documentation in HTML format to file.'), 'default' => false))->addOption('testdox-text', array('help' => __d('cake_console', '<file> Write agile documentation in Text format to file.'), 'default' => false))->addOption('filter', array('help' => __d('cake_console', '<pattern> Filter which tests to run.'), 'default' => false))->addOption('group', array('help' => __d('cake_console', '<name> Only runs tests from the specified group(s).'), 'default' => false))->addOption('exclude-group', array('help' => __d('cake_console', '<name> Exclude tests from the specified group(s).'), 'default' => false))->addOption('list-groups', array('help' => __d('cake_console', 'List available test groups.'), 'boolean' => true))->addOption('loader', array('help' => __d('cake_console', 'TestSuiteLoader implementation to use.'), 'default' => false))->addOption('repeat', array('help' => __d('cake_console', '<times> Runs the test(s) repeatedly.'), 'default' => false))->addOption('tap', array('help' => __d('cake_console', 'Report test execution progress in TAP format.'), 'boolean' => true))->addOption('testdox', array('help' => __d('cake_console', 'Report test execution progress in TestDox format.'), 'default' => false, 'boolean' => true))->addOption('no-colors', array('help' => __d('cake_console', 'Do not use colors in output.'), 'boolean' => true))->addOption('stderr', array('help' => __d('cake_console', 'Write to STDERR instead of STDOUT.'), 'boolean' => true))->addOption('stop-on-error', array('help' => __d('cake_console', 'Stop execution upon first error or failure.'), 'boolean' => true))->addOption('stop-on-failure', array('help' => __d('cake_console', 'Stop execution upon first failure.'), 'boolean' => true))->addOption('stop-on-skipped', array('help' => __d('cake_console', 'Stop execution upon first skipped test.'), 'boolean' => true))->addOption('stop-on-incomplete', array('help' => __d('cake_console', 'Stop execution upon first incomplete test.'), 'boolean' => true))->addOption('strict', array('help' => __d('cake_console', 'Mark a test as incomplete if no assertions are made.'), 'boolean' => true))->addOption('wait', array('help' => __d('cake_console', 'Waits for a keystroke after each test.'), 'boolean' => true))->addOption('process-isolation', array('help' => __d('cake_console', 'Run each test in a separate PHP process.'), 'boolean' => true))->addOption('no-globals-backup', array('help' => __d('cake_console', 'Do not backup and restore $GLOBALS for each test.'), 'boolean' => true))->addOption('static-backup', array('help' => __d('cake_console', 'Backup and restore static attributes for each test.'), 'boolean' => true))->addOption('syntax-check', array('help' => __d('cake_console', 'Try to check source files for syntax errors.'), 'boolean' => true))->addOption('bootstrap', array('help' => __d('cake_console', '<file> A "bootstrap" PHP file that is run before the tests.'), 'default' => false))->addOption('configuration', array('help' => __d('cake_console', '<file> Read configuration from XML file.'), 'default' => false))->addOption('no-configuration', array('help' => __d('cake_console', 'Ignore default configuration file (phpunit.xml).'), 'boolean' => true))->addOption('include-path', array('help' => __d('cake_console', '<path(s)> Prepend PHP include_path with given path(s).'), 'default' => false))->addOption('directive', array('help' => __d('cake_console', 'key[=value] Sets a php.ini value.'), 'default' => false))->addOption('fixture', array('help' => __d('cake_console', 'Choose a custom fixture manager.')))->addOption('debug', array('help' => __d('cake_console', 'More verbose output.')));
     return $parser;
 }
Ejemplo n.º 6
0
 /**
  * ConvertShell::getOptionParser()
  *
  * @return ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $subcommandParser = array('options' => array('plugin' => array('short' => 'p', 'help' => 'The plugin to update. Only the specified plugin will be updated.', 'default' => ''), 'dry-run' => array('short' => 'd', 'help' => 'Dry run the update, no files will actually be modified.', 'boolean' => true), 'ext' => array('short' => 'e', 'help' => 'The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern', 'default' => 'php')), 'arguments' => ['path' => ['help' => 'Path to folder, defaults to current APP otherwise.']]);
     $name = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
     $parser = new ConsoleOptionParser($name);
     return $parser->description("A shell to help automate upgrading array syntax to PHP5.4")->addSubcommand('run', array('help' => 'Update verbose array syntax to short one.', 'parser' => $subcommandParser));
 }
 /**
  * ConvertShell::getOptionParser()
  *
  * @return ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $subcommandParser = array('options' => array('plugin' => array('short' => 'p', 'help' => __d('cake_console', 'The plugin to update. Only the specified plugin will be updated.'), 'default' => ''), 'dry-run' => array('short' => 'd', 'help' => __d('cake_console', 'Dry run the update, no files will actually be modified.'), 'boolean' => true), 'ext' => array('short' => 'e', 'help' => __d('cake_console', 'The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern'), 'default' => 'php')));
     $name = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
     $parser = new ConsoleOptionParser($name);
     return $parser->description(__d('cake_console', "A shell to help automate upgrading array syntax to PHP5.4"))->addSubcommand('arrays', array('help' => __d('cake_console', 'Main method to update verbose array syntax to short one.'), 'parser' => $subcommandParser));
 }