public function testGetViolations() { $sourceFilterMock = $this->getMockBuilder('Mathielen\\DataImport\\Filter\\ValidatorFilter')->disableOriginalConstructor()->getMock(); $sourceFilterMock->expects($this->once())->method('getViolations')->will($this->returnValue('sourceViolation')); $targetFilterMock = $this->getMockBuilder('Mathielen\\DataImport\\Filter\\ValidatorFilter')->disableOriginalConstructor()->getMock(); $targetFilterMock->expects($this->once())->method('getViolations')->will($this->returnValue('targetViolation')); $this->validatorValidation->setSourceValidatorFilter($sourceFilterMock); $this->validatorValidation->setTargetValidatorFilter($targetFilterMock); $workflow = $this->getMockBuilder('Ddeboer\\DataImport\\Workflow')->disableOriginalConstructor()->getMock(); $this->assertEquals(array('source' => 'sourceViolation', 'target' => 'targetViolation'), $this->validatorValidation->getViolations()); }
/** * @medium */ public function test() { $data1 = [['foo' => 'bar1']]; $data2 = [['foo' => 'bar2']]; $targetData = array(); $targetStorage = new ArrayStorage($targetData); $validator = Validation::createValidator(); $validation = new ValidatorValidation($validator); $validation->addSourceConstraint('foo', new Choice(['choices' => ['a']])); $importer = Importer::build($targetStorage); $importer->validation($validation); $importRunner = ImportRunner::build(); $import = Import::build($importer, new ArrayStorage($data1)); $importRunner->dryRun($import); $this->assertEquals(1, count($importer->validation()->getViolations()['source'])); $import = Import::build($importer, new ArrayStorage($data2)); $importRunner->dryRun($import); $this->assertEquals(1, count($importer->validation()->getViolations()['source'])); }