public function CSVUnitTest::testInitializeIterator in Migrate Source CSV 8.3
Same name and namespace in other branches
- 8.2 tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php \Drupal\Tests\migrate_source_csv\Unit\Plugin\migrate\source\CSVUnitTest::testInitializeIterator()
Tests initialization of the iterator.
@covers ::initializeIterator @dataProvider iteratorDataProvider
Parameters
array $configuration: The plugin configuration.
array $expected: The expected results.
File
- tests/
src/ Unit/ Plugin/ migrate/ source/ CSVUnitTest.php, line 146
Class
- CSVUnitTest
- @coversDefaultClass \Drupal\migrate_source_csv\Plugin\migrate\source\CSV
Namespace
Drupal\Tests\migrate_source_csv\Unit\Plugin\migrate\sourceCode
public function testInitializeIterator(array $configuration, array $expected) : void {
$file_path = $this->standardCharsPath;
if (isset($configuration['path']) && $configuration['path'] === 'non standard') {
$file_path = $this->nonStandardCharsPath;
}
// Set the file path here so the virtual stream can be created in setUp.
$configuration['path'] = $file_path;
$csv = new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration);
$iterator = $csv
->initializeIterator();
$this
->assertEquals(count($expected), iterator_count($iterator));
$iterator = $csv
->initializeIterator();
foreach ($expected as $record) {
$this
->assertSame($record, $iterator
->current());
$iterator
->next();
}
}