Exemplo n.º 1
0
 public function testOffsetUnset()
 {
     $this->setExpectedException('LogicException');
     $option = new Option('a', 'arg', Getopt::REQUIRED_ARGUMENT);
     $option->setDefaultValue('plus');
     $getopt = new Getopt(array($option));
     $getopt->parse('');
     unset($getopt['a']);
 }
 public function testAFlagWithDefaultTrue()
 {
     $opt = new Option('a', null, Getopt::IS_FLAG);
     $opt->setDefaultValue(true);
     $parser = new CommandLineParser(array($opt));
     $parser->parse('');
     $options = $parser->getOptions();
     $this->assertTrue($options['a']->getValue());
     $this->assertTrue($options['a']->getIsDefault());
     $parser = new CommandLineParser(array($opt));
     $parser->parse('-a');
     $options = $parser->getOptions();
     $this->assertFalse($options['a']->getValue());
     $this->assertFalse($options['a']->getIsDefault());
 }