Ejemplo n.º 1
0
 /**
  * Does this switch require an argument?
  *
  * @return boolean
  */
 public function testHasRequiredArgument()
 {
     if (!$this->arg instanceof DefinedArg) {
         return false;
     }
     return $this->arg->testIsRequired();
 }
Ejemplo n.º 2
0
 public function testGetsErrorMessagesWhenValidationFails()
 {
     $name = '<command>';
     $desc = 'The <command> you need help with';
     $obj = new DefinedArg($name, $desc);
     $obj->setValidator(new MustBeValidPath());
     $this->assertEquals($name, $obj->name);
     $this->assertEquals($desc, $obj->desc);
     $this->assertTrue($obj->testIsOptional());
     $this->assertTrue($obj->testMustValidateWith('Gradwell\\ValidationLib\\MustBeValidPath'));
     // now, validate the data
     $return = $obj->testIsValid(__FILE__);
     $this->assertTrue(is_array($return));
     $this->assertEquals(1, count($return));
     // we do not need to test the actual error message here
     // as the error message may change in future releases
     //
     // simply having an error message is enough
 }