public function testShouldReturnOptionValueWithOneValue() { $argumentValue = 'test'; $parser = new CliParser(); $parser->setOptions(array('-l' => 'alpha')); $parser->setInput('-l ' . $argumentValue); $this->assertEquals($argumentValue, $parser->value('-l')); }
public function run() { $command = $this->cli->getCommand(); $className = "DBtrack\\Commands\\{$command}"; if (!class_exists($className)) { throw new \Exception('Invalid command: ' . $command); } $command = new $className($this->cli->getOptions()); $command->execute(); }
/** * */ public function testParse() { $arr = array('-a', '-b=foo', '-c', 'bar', '--export', '--foo=bar', '-xyz', '-=asd', 'bluff', 'inva--lid', '--test', 'value', '-q', 'woho'); $this->object->parse($arr); $this->assertTrue($this->object->getValue('-a')); $this->assertEquals('foo', $this->object->getValue('-b')); $this->assertEquals('bar', $this->object->getValue('-c')); $this->assertTrue($this->object->getValue('--export')); $this->assertEquals('bar', $this->object->getValue('--foo')); $this->assertTrue($this->object->getValue('-x')); $this->assertTrue($this->object->getValue('-y')); $this->assertTrue($this->object->getValue('-z')); }
/** * Overrides base class, takes aliases into account * * @param string $flag * * @return string|bool Returns the value of the flag, string or bool according to the flag */ public function getValue($flag) { $f = $this->getFlag($flag); if ($f) { if (array_key_exists($flag, $this->flags)) { return parent::getValue($f->getName()); } } return false; }