/** * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException * @expectedExceptionMessage Expected argument of type "FormInterface", "array" given */ public function testValidateExceptionWhenInvalidRootType() { $this->context = $this->getMock('\\Symfony\\Component\\Validator\\ExecutionContextInterface'); $this->context->expects($this->any())->method('getRoot')->will($this->returnValue(array())); $validator = new DateEarlierThanValidator(); $validator->initialize($this->context); $validator->validate($this->dateTimeStart, $this->constraint); }
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)); }
public function testValidateExceptionWhenRootTypeIsNotForm() { $data = new \stdClass(); $data->start = new \DateTime(); $data->end = new \DateTime(); $this->context = $this->getMock('\\Symfony\\Component\\Validator\\ExecutionContextInterface'); $this->context->expects($this->any())->method('getRoot')->will($this->returnValue($data)); $this->context->expects($this->never())->method('addViolation'); $validator = new DateEarlierThanValidator(); $validator->initialize($this->context); $validator->validate($this->dateTimeStart, $this->constraint); }