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()); }
/** * @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); }