Example #1
0
 public function testSetGetValidator()
 {
     $ruleSet = new RuleSet();
     $ruleSet->setRule('required', $this->createRequiredRule());
     $validator = new Validator($ruleSet, 'required', 'required field');
     $this->field->setValidator($validator);
     $this->assertSame($validator, $this->field->getValidator());
 }
Example #2
0
 /**
  * @expectedException \LiftKit\Form\Validator\Rule\Exception\Validation
  */
 public function testExecuteValidates()
 {
     $input = new Request([]);
     $ruleSet = new RuleSet();
     $ruleSet->setRule('required', new Rule(function ($value) {
         return (bool) $value;
     }, 'The field is required'));
     $element = new Field();
     $element->setValidator(new Validator($ruleSet, 'required'));
     $this->fieldSet->attachElement($element);
     $this->fieldSet->execute($input);
 }