Exemplo n.º 1
0
 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);
 }