Beispiel #1
0
 /**
  * @param array $rules
  * @param array $values
  * @returns bool
  */
 public function validate(array $rules, array $values)
 {
     $validator = $this->factory->make($rules);
     $status = $validator->validate($values);
     $this->lastValidationMessages = $validator->getMessages();
     return $status;
 }
 function it_should_validate_data_and_return_fail(ValidatorFactoryInterface $factory, ValidatorInterface $validator, ElementInterface $el)
 {
     $rules = ['foo' => 'required'];
     $values = ['foo' => ''];
     $errors = ['foo' => ['Foo element is required.']];
     $elements = ['foo' => $el];
     $factory->make($rules)->willReturn($validator);
     $validator->validate($values)->willReturn(false);
     $validator->getMessages()->willReturn($errors);
     $el->getName()->willReturn('foo');
     $el->setInvalid(json_encode($errors['foo']))->shouldBeCalled();
     $this->validate($rules, $values)->shouldReturn(false);
     $this->updateValidationStatus($elements);
 }