public function CSVUnitTest::testFields in Migrate Source CSV 8.2
Same name and namespace in other branches
- 8.3 tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php \Drupal\Tests\migrate_source_csv\Unit\Plugin\migrate\source\CSVUnitTest::testFields()
Tests that fields have a machine name and description.
@covers ::fields
File
- tests/
src/ Unit/ Plugin/ migrate/ source/ CSVUnitTest.php, line 277
Class
- CSVUnitTest
- @coversDefaultClass \Drupal\migrate_source_csv\Plugin\migrate\source\CSV
Namespace
Drupal\Tests\migrate_source_csv\Unit\Plugin\migrate\sourceCode
public function testFields() {
$configuration = [
'path' => $this->happyPath,
'keys' => [
'id',
],
'header_row_count' => 1,
];
$fields = [
'id' => 'identifier',
'first_name' => 'User first name',
];
$expected = $fields + [
'last_name' => 'last_name',
'email' => 'email',
'country' => 'country',
'ip_address' => 'ip_address',
];
$csv = new CSV($configuration + [
'fields' => $fields,
], $this->pluginId, $this->pluginDefinition, $this->migration);
$this
->assertArrayEquals($expected, $csv
->fields());
$column_names = [
0 => [
'id' => 'identifier',
],
2 => [
'first_name' => 'User first name',
],
];
$csv = new CSV($configuration + [
'fields' => $fields,
'column_names' => $column_names,
], $this->pluginId, $this->pluginDefinition, $this->migration);
$this
->assertArrayEquals($fields, $csv
->fields());
}