Exemplo n.º 1
0
 /**
  * Add a option object to this command.
  *
  * @param   mixed   $option       The option name. Can be a string, an array or an object.
  *                                 If we use array, the first element will be option name, others will be alias.
  * @param   mixed   $default      The default value when we get a non-exists option.
  * @param   string  $description  The option description.
  *
  * @return  Option  Return Option object.
  *
  * @since   2.0
  */
 public function addGlobalOption($option, $default = null, $description = null)
 {
     if (!$option instanceof Option) {
         $option = new Option($option, $default, $description);
     }
     $option->setGlobal(Option::IS_GLOBAL);
     $option->setIO($this->io);
     $name = $option->getName();
     $this->globalOptions[$name] = $option;
     // Global option should not equal to private option
     unset($this->options[$name]);
     // We should pass global option to all children.
     foreach ($this->children as $child) {
         $child->addGlobalOption($option);
     }
     return $option;
 }
Exemplo n.º 2
0
 /**
  * Test set & get name.
  *
  * @return void
  *
  * @since  2.0
  */
 public function testSetAndGetName()
 {
     $this->instance->setName('defaulttt');
     $this->assertEquals('defaulttt', $this->instance->getName(), 'Name value not matched.');
 }