/** * Test set & get name. * * @return void * * @since 1.0 */ public function testSetAndGetName() { $this->instance->setName('defaulttt'); $this->assertEquals('defaulttt', $this->instance->getName(), 'Name value not matched.'); }
/** * 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. * @param bool $global If true, this option will be a global option that sub commends will extends it. * * @return AbstractCommand Return this object to support chaining. * * @since 1.0 */ public function addOption($option, $default = null, $description = null, $global = false) { if (!$option instanceof Option) { $option = new Option($option, $default, $description, $global); } $option->setInput($this->input); $name = $option->getName(); $global = $option->isGlobal(); if ($global) { $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->addOption($option); } } else { $this->options[$name] = $option; // Global option should not equal to private option unset($this->globalOptions[$name]); } return $this; }