diff --git a/src/Plugin/migrate/source/CSV.php b/src/Plugin/migrate/source/CSV.php index 7cd2679f8b88418dc788788730f130edda040e19..eef439847a23f7d89995d9bfe62bad6dafb28acb 100644 --- a/src/Plugin/migrate/source/CSV.php +++ b/src/Plugin/migrate/source/CSV.php @@ -14,10 +14,7 @@ use League\Csv\Reader; * Available configuration options: * - path: Path to the CSV file. File streams are supported. Use /dev/null to * get an empty source (useful for migration_lookup). - * - ids: Array of column names that uniquely identify each record. Column - * names used as IDs can only contain letters (uppercase and lowercase), - * numbers (0-9), and underscores. No spaces or other special characters - * are allowed. + * - ids: Array of column names that uniquely identify each record. * - header_offset: (optional) The record to be used as the CSV header and the * thereby each record's field name. Defaults to 0 and because records are * zero indexed. Can be set to null to indicate no header record. @@ -122,12 +119,6 @@ class CSV extends SourcePluginBase implements ConfigurableInterface { if ($this->configuration['ids'] !== array_unique(array_filter($this->configuration['ids'], 'is_string'))) { throw new \InvalidArgumentException('The ids must a flat array with unique string values.'); } - foreach ($this->configuration['ids'] as $id) { - if (!preg_match('/^\w+$/', $id)) { - throw new \InvalidArgumentException(sprintf('The id (%s) must only include word characters a-z, A-Z, 0-9, including _ (underscore).', $id)); - } - } - // CSV character control characters must be exactly 1 character. foreach (['delimiter', 'enclosure', 'escape'] as $character) { if (1 !== strlen($this->configuration[$character])) { diff --git a/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php b/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php index e8d38e9a3c5fec83e58b5aac0d9e36944ec31e79..691cee2464d009281e9ee7c6997df0c5259237c9 100644 --- a/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php +++ b/tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php @@ -118,35 +118,6 @@ EOD; new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); } - /** - * Tests that valid IDs are validated. - */ - public function testValidIds(): void { - $configuration = [ - 'path' => $this->standardCharsPath, - 'ids' => [ - 'asdfASDF_', - ], - ]; - $csv = new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); - $this->assertInstanceOf(CSV::class, $csv); - } - - /** - * Tests invalid IDs are validated. - */ - public function testInvalidIds(): void { - $configuration = [ - 'path' => $this->standardCharsPath, - 'ids' => [ - 'asdfASDF_-', - ], - ]; - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('The id (asdfASDF_-) must only include word characters a-z, A-Z, 0-9, including _ (underscore).'); - new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration); - } - /** * Tests that toString functions as expected. *