public function testSecretGenerateCommand() { $name = 'secret:generate'; $commands = Console::getCommands(); $this->assertTrue(isset($commands[$name])); $cmd = $commands[$name]; list($args, $opts) = $cmd->parseArguments(array('--method', 'sha1', '--data', 'hello')); $this->assertEqual($opts, array('help' => null, 'method' => 'sha1', 'data' => 'hello')); $this->assertEqual($args, array()); list($args, $opts) = $cmd->parseArguments(array('--method=sha1', '--data=hello')); $this->assertEqual($opts, array('help' => null, 'method' => 'sha1', 'data' => 'hello')); $this->assertEqual($args, array()); list($args, $opts) = $cmd->parseArguments(array('-m', 'sha1', '--data=hello')); $this->assertEqual($opts, array('help' => null, 'method' => 'sha1', 'data' => 'hello')); $this->assertEqual($args, array()); list($args, $opts) = $cmd->parseArguments(array('-m', 'sha1', '-d', 'hello')); $this->assertEqual($opts, array('help' => null, 'method' => 'sha1', 'data' => 'hello')); $this->assertEqual($args, array()); list($args, $opts) = $cmd->parseArguments(array('-m=sha1', '-d=hello')); $this->assertEqual($opts, array('help' => null, 'method' => 'sha1', 'data' => 'hello')); $this->assertEqual($args, array()); list($args, $opts) = $cmd->parseArguments(array('-m=sha1', '--data=hello world')); $this->assertEqual($opts, array('help' => null, 'method' => 'sha1', 'data' => 'hello world')); $this->assertEqual($args, array()); list($args, $opts) = $cmd->parseArguments(array('--data=hello world')); $this->assertEqual($opts, array('help' => null, 'method' => 'md5', 'data' => 'hello world')); $this->assertEqual($args, array()); list($args, $opts) = $cmd->parseArguments(array('--method=sha1')); $this->assertEqual($opts, array('help' => null, 'method' => 'sha1', 'data' => null)); $this->assertEqual($args, array()); }
/** * Simple helper to get all registered commands * @since PHPLucidFrame v 1.12.0 * @return array */ function _consoleCommands() { return Console::getCommands(); }
/** * Register a command * @return object LucidFrame\Console\Command` */ public function register() { Console::registerCommand($this); return $this; }