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());
 }
Ejemplo n.º 2
0
/**
 * Simple helper to get all registered commands
 * @since  PHPLucidFrame v 1.12.0
 * @return array
 */
function _consoleCommands()
{
    return Console::getCommands();
}
Ejemplo n.º 3
0
 /**
  * Register a command
  * @return object LucidFrame\Console\Command`
  */
 public function register()
 {
     Console::registerCommand($this);
     return $this;
 }