/** * @return ValidatorValidation */ public function addTargetConstraint($field, Constraint $constraint) { if (!$this->targetValidatorFilter) { $this->setTargetValidatorFilter(new ValidatorFilter($this->validator)); $this->targetValidatorFilter->setAllowExtraFields(true); } $this->targetValidatorFilter->add($field, $constraint); return $this; }
public function testOptions() { $this->validatorFilter->setAllowExtraFields(true); $this->validatorFilter->setAllowMissingFields(true); $this->validatorFilter->add('field1', new NotBlank()); $item = array('field1', 'field2'); $constraints = new Constraints\Collection(array('allowExtraFields' => true, 'allowMissingFields' => true, 'fields' => array('field1' => new NotBlank()))); $this->validatorMock->expects($this->once())->method('validateValue')->with($item, $constraints); $this->validatorFilter->filter($item); }
public function testApply() { $this->validatorValidation->addSourceConstraint('sourceField', new Email()); $this->validatorValidation->addTargetConstraint('targetField', new NotNull()); $expectedSourceFilter = new ValidatorFilter($this->validatorMock); $expectedSourceFilter->setAllowExtraFields(true); $expectedSourceFilter->add('sourceField', new Email()); $expectedTargetFilter = new ValidatorFilter($this->validatorMock); $expectedTargetFilter->setAllowExtraFields(true); $expectedTargetFilter->add('targetField', new NotNull()); $workflow = $this->getMockBuilder('Ddeboer\\DataImport\\Workflow')->disableOriginalConstructor()->getMock(); $workflow->expects($this->once())->method('addFilter')->with($expectedSourceFilter); $workflow->expects($this->once())->method('addFilterAfterConversion')->with($expectedTargetFilter); $this->validatorValidation->apply($workflow); }