Skip to content
Snippets Groups Projects
Commit 537c9720 authored by godotislate's avatar godotislate Committed by Lucas Hedding
Browse files

Issue #3413894 by b2f, godotislate, heddn: Revert requirement that IDs not include spaces

parent 24c0986b
Branches 8.x-3.x
No related tags found
1 merge request!8Revert "Issue #3379184 by dinarcon, heddn: Document that source IDs can only...
Pipeline #388728 passed
......@@ -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])) {
......
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment