Loading src/Plugin/migrate/source/CSV.php +7 −2 Original line number Diff line number Diff line Loading @@ -120,8 +120,13 @@ class CSV extends SourcePluginBase { */ public function getIDs() { $ids = []; foreach ($this->configuration['keys'] as $key) { $ids[$key]['type'] = 'string'; foreach ($this->configuration['keys'] as $delta => $value) { if (is_array($value)) { $ids[$delta] = $value; } else { $ids[$value]['type'] = 'string'; } } return $ids; } Loading tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php +32 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,38 @@ class CSVUnitTest extends CSVUnitBase { $this->assertArrayEquals($expected, $csv->getIds()); } /** * Tests that the key is properly identified. * * @covers ::getIds */ public function testGetIdsComplex() { $configuration = [ 'path' => $this->happyPath, 'keys' => [ 'id', 'paragraph' => [ 'type' => 'text', 'size' => 'big', ], ], 'header_row_count' => 1, ]; $csv = new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); $expected = [ 'id' => [ 'type' => 'string', ], 'paragraph' => [ 'type' => 'text', 'size' => 'big', ], ]; $this->assertArrayEquals($expected, $csv->getIds()); } /** * Tests that fields have a machine name and description. * Loading Loading
src/Plugin/migrate/source/CSV.php +7 −2 Original line number Diff line number Diff line Loading @@ -120,8 +120,13 @@ class CSV extends SourcePluginBase { */ public function getIDs() { $ids = []; foreach ($this->configuration['keys'] as $key) { $ids[$key]['type'] = 'string'; foreach ($this->configuration['keys'] as $delta => $value) { if (is_array($value)) { $ids[$delta] = $value; } else { $ids[$value]['type'] = 'string'; } } return $ids; } Loading
tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php +32 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,38 @@ class CSVUnitTest extends CSVUnitBase { $this->assertArrayEquals($expected, $csv->getIds()); } /** * Tests that the key is properly identified. * * @covers ::getIds */ public function testGetIdsComplex() { $configuration = [ 'path' => $this->happyPath, 'keys' => [ 'id', 'paragraph' => [ 'type' => 'text', 'size' => 'big', ], ], 'header_row_count' => 1, ]; $csv = new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); $expected = [ 'id' => [ 'type' => 'string', ], 'paragraph' => [ 'type' => 'text', 'size' => 'big', ], ]; $this->assertArrayEquals($expected, $csv->getIds()); } /** * Tests that fields have a machine name and description. * Loading