public function testParseInvalidArgument()
 {
     $this->setExpectedException('UnexpectedValueException');
     $validation = 'is_numeric';
     $option = new Option('a', null, Getopt::OPTIONAL_ARGUMENT);
     $option->setArgument(new Argument(null, $validation));
     $parser = new CommandLineParser(array($option));
     $parser->parse('-a nonnumeric');
 }
 /**
  * @param array $row
  *
  * @return Option
  */
 private function createOption(array $row)
 {
     $rowSize = count($row);
     if ($rowSize < 3) {
         $row = $this->completeOptionArray($row);
     }
     $option = new Option($row[0], $row[1], $row[2]);
     if ($rowSize >= 4) {
         $option->setDescription($row[3]);
     }
     if ($rowSize >= 5 && $row[2] != Getopt::NO_ARGUMENT) {
         $option->setArgument(new Argument($row[4]));
     }
     return $option;
 }
Beispiel #3
0
 public function testSetArgumentWrongMode()
 {
     $this->setExpectedException('InvalidArgumentException');
     $option = new Option('a', null, Getopt::NO_ARGUMENT);
     $option->setArgument(new Argument());
 }