public function testNotExistingFormData() { $formConfig = $this->getMock('\\Symfony\\Component\\Form\\FormConfigInterface'); $form = new Form($formConfig); $this->context = $this->getMock('\\Symfony\\Component\\Validator\\ExecutionContextInterface'); $this->context->expects($this->any())->method('getRoot')->will($this->returnValue($form)); $this->validator->initialize($this->context); $this->assertNull($this->validator->validate(false, $this->constraint)); }
/** * @dataProvider getInvalidValues */ public function testInvalidValues($value) { $this->context->expects($this->once())->method('addViolation'); $constraint = new User(); $this->validator->validate($value, $constraint); }
public function testInvalidData() { $this->formField->expects($this->any())->method('getData')->will($this->returnValue($this->dateTimeStart)); $this->context->expects($this->once())->method('addViolation')->with($this->equalTo($this->constraint->message), $this->equalTo(array('{{ ' . $this->constraint->getDefaultOption() . ' }}' => $this->constraint->field))); $this->validator->validate($this->dateTimeEnd, $this->constraint); }