public function testCannotSetOptionsOnArgUntilItIsDefined()
 {
     $name = 'help';
     $desc = 'display this help message';
     $shortSwitch = 'h';
     $obj = new DefinedSwitch($name, $desc);
     $obj->setWithShortSwitch($shortSwitch);
     $caughtException = false;
     try {
         $obj->setArgHasDefaultValueOf(0);
     } catch (\Exception $e) {
         $caughtException = true;
     }
     $this->assertTrue($caughtException);
     $caughtException = false;
     try {
         $obj->setArgValidator(new MustBeValidPath());
     } catch (\Exception $e) {
         $caughtException = true;
     }
     $this->assertTrue($caughtException);
 }
 public function testValidationReturnsArrayOfErrorsIfValidationsFail()
 {
     // first, we need a definition
     $name = 'Fred';
     $desc = 'Fred is a jolly fellow';
     $def = new DefinedSwitch($name, $desc);
     $this->assertEquals($def->name, $name);
     $this->assertEquals($def->desc, $desc);
     $def->setWithRequiredArg('harry', 'harry does love his food');
     $def->setArgValidator(new MustBeInteger());
     // now, we use the definition to create
     // the ParsedSwitch
     $obj = new ParsedSwitch($def);
     // add a value for the validator
     $obj->addValue('trout');
     // run the validation
     $result = $obj->validateValues();
     $this->assertTrue(is_array($result));
     $this->assertEquals(1, count($result));
 }