Ejemplo n.º 1
0
 /**
  * Force form validation.
  *
  * @return bool
  */
 public function validate()
 {
     $rules = [];
     foreach ($this->elements as $element) {
         $rules[$element->getName()] = $element->getValidationRules();
     }
     $this->valid = $this->validationHelper->validate($rules, $this->getData());
     $this->validationHelper->updateValidationStatus($this->elements);
     return $this->valid;
 }
Ejemplo n.º 2
0
 function it_binds_validator(Request $request, Validator $validator, ElementInterface $textElement)
 {
     $request->get(DeForm::DEFORM_ID)->willReturn('testform');
     $request->get('foo')->willReturn('test');
     $textElement->getValidationRules()->willReturn('required');
     $textElement->isReadonly()->willReturn(false);
     $textElement->setValue('test')->willReturn(false);
     $textElement->getValue()->willReturn('test');
     $validator->validate(['foo' => 'required'], Argument::any())->shouldBeCalled();
     $validator->updateValidationStatus(Argument::any())->shouldBeCalled();
     $this->make($this->html)->isValid();
 }
Ejemplo n.º 3
0
 function it_fails_validate_data(Request $request, ValidationHelper $validationHelper, Element $el1)
 {
     // Submitted form
     $request->get(DeForm::DEFORM_ID)->willReturn('foo');
     $request->get('foo')->willReturn('bar');
     $el1->isReadonly()->willReturn(true);
     $el1->getName()->willReturn('foo');
     $el1->getValue()->willReturn('bar');
     $el1->getValidationRules()->willReturn('required');
     $this->addElement($el1);
     $rules = ['foo' => 'required'];
     $values = ['foo' => 'bar'];
     $elements = ['foo' => $el1];
     $validationHelper->validate($rules, $values)->willReturn(false);
     $validationHelper->updateValidationStatus($elements)->shouldBeCalled();
     $this->shouldNotBeValid();
 }