public function test_ParseSpecTextLines() { $text = <<<EOT -i <id> specify an id (required) -l, --list operate in list mode EOT; $this->assertEquals(array(array('short' => 'i', 'long' => false, 'value_name' => 'id', 'help' => 'specify an id', 'required' => true), array('short' => 'l', 'long' => 'list', 'value_name' => false, 'help' => 'operate in list mode', 'required' => false)), iterator_to_array(TextSpecParser::createArgumentsSpec($text))); }
/** * create a new CLIOpts parser from a text specification * * @param string $arguments_spec_text a text specification of expected arguments and options * * @see TextSpecParser * @return CLIOpts a CLIOpts parser. */ public static function createFromTextSpec($arguments_spec_text) { return new self(TextSpecParser::createArgumentsSpec($arguments_spec_text)); }
protected function verifyParsedArgs($text_spec, $fake_argv, $expected_result) { $arguments_spec = TextSpecParser::createArgumentsSpec($text_spec); $parsed_args = ArgumentsParser::parseArgvWithSpec($fake_argv, $arguments_spec); $this->assertEquals($expected_result, $parsed_args); }