diff --git a/src/Mathielen/DataImport/ItemConverter/FieldLowercaseConverter.php b/src/Mathielen/DataImport/ItemConverter/FieldLowercaseConverter.php new file mode 100644 index 0000000..34fd29c --- /dev/null +++ b/src/Mathielen/DataImport/ItemConverter/FieldLowercaseConverter.php @@ -0,0 +1,14 @@ +addValueConverter($from, $converter); + $workflow->addValueConverter($to, $converter); } elseif ($converter instanceof ItemConverterInterface) { $workflow->addItemConverter($converter); } diff --git a/src/Mathielen/ImportEngine/Storage/LocalFileStorage.php b/src/Mathielen/ImportEngine/Storage/LocalFileStorage.php index f6a184e..dc1a960 100644 --- a/src/Mathielen/ImportEngine/Storage/LocalFileStorage.php +++ b/src/Mathielen/ImportEngine/Storage/LocalFileStorage.php @@ -88,7 +88,7 @@ private function formatToReader(Format $format, \SplFileInfo $file) $reader = new CsvReader($file->openFile(), $format->getDelimiter(), $format->getEnclosure(), $format->getEscape()); $reader->setStrict(false); if ($format->isHeaderInFirstRow()) { - $reader->setHeaderRowNumber(0); + $reader->setHeaderRowNumber(0, CsvReader::DUPLICATE_HEADERS_MERGE); $reader->setColumnHeaders(array_map('trim', $reader->getColumnHeaders())); //TODO some header-collaborator? } diff --git a/tests/integration/Mathielen/ImportEngine/Import/Run/ImportRunnerTest.php b/tests/integration/Mathielen/ImportEngine/Import/Run/ImportRunnerTest.php index 17015ef..70a6b95 100644 --- a/tests/integration/Mathielen/ImportEngine/Import/Run/ImportRunnerTest.php +++ b/tests/integration/Mathielen/ImportEngine/Import/Run/ImportRunnerTest.php @@ -59,14 +59,14 @@ public function test() $import = $importBuilder->build($importRequest); $import->mappings() - ->add('Anrede', 'salutation', 'upperCase') - ->add('Name', 'name', 'lowerCase'); + ->add('prefix', 'Anrede', 'upperCase') + ->add('name', 'Name', 'lowerCase'); $importRunner = new ImportRunner(new DefaultWorkflowFactory($eventDispatcher)); $expectedResult = array( - 'name' => 'Jennie Abernathy', - 'prefix' => 'Ms.', + 'Name' => 'jennie abernathy', + 'Anrede' => 'MS.', 'street' => '866 Hyatt Isle Apt. 888', 'zip' => '65982', 'city' => 'East Laurie',