/** * Test get value. * * @param array $inputs The input option. * * @dataProvider optionProvider * * @return void * * @since 2.0 */ public function testGetValue($inputs) { foreach ($inputs as $key => $vals) { $this->instance->getIO()->setOption($key, 1); foreach ($vals as $val) { $this->assertEquals(1, $this->instance->getValue($val)); } } // Filter $this->instance->getIO()->setOption('y', 'flower sakura'); $this->assertEquals('flower sakura', $this->instance->getValue('y'), 'Default input filter should string.'); }
/** * 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; }