public function testValidateInvalidField() { $constraint = new ContactInformationColumnConstraint(); $constraint->field = 'test'; $value = new \stdClass(); $value->test = $this->getMockForAbstractClass('Oro\\Bundle\\QueryDesignerBundle\\Model\\AbstractQueryDesigner'); $this->contactInformationFieldHelper->expects($this->once())->method('getQueryContactInformationColumns')->with($value->test)->will($this->returnValue(array())); $this->context->expects($this->once())->method('addViolationAt')->with($constraint->field, $constraint->message); $this->validator->validate($value, $constraint); }
/** * @dataProvider validatorDataProvider * @param string $type * @param array $contactInformationFields */ public function testValidateInvalidField($type, array $contactInformationFields) { $constraint = new ContactInformationColumnConstraint(); $constraint->field = 'test'; $constraint->type = $type; $value = new \stdClass(); $value->test = $this->getMockForAbstractClass('Oro\\Bundle\\QueryDesignerBundle\\Model\\AbstractQueryDesigner'); $this->contactInformationFieldHelper->expects($this->once())->method('getQueryContactInformationColumns')->with($value->test)->will($this->returnValue($contactInformationFields)); $parameters = []; if ($type) { $message = $constraint->typeMessage; $parameters['%type%'] = $type; } else { $message = $constraint->message; } $this->context->expects($this->once())->method('addViolationAt')->with($constraint->field, $message, $parameters); $this->validator->validate($value, $constraint); }