You are here

public function CSVUnitTest::testConfigurableCsvFileObjectFlags in Migrate Source CSV 8.2

Tests configurable CSV file object.

@covers ::current @covers ::rewind

File

tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php, line 335

Class

CSVUnitTest
@coversDefaultClass \Drupal\migrate_source_csv\Plugin\migrate\source\CSV

Namespace

Drupal\Tests\migrate_source_csv\Unit\Plugin\migrate\source

Code

public function testConfigurableCsvFileObjectFlags() {
  $configuration = [
    'path' => $this->multiLine,
    'keys' => [
      'id',
    ],
    'header_row_count' => 1,
    'file_flags' => \SplFileObject::READ_CSV | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY,
  ];
  $csv = new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration);
  $csv_file_object = $csv
    ->initializeIterator();
  $row = [
    'id' => '1',
    'title' => 'Title 1',
    'description' => "Description 1 Line 1\nDescription 1 Line 2\nDescription 1 Line 3",
  ];
  $csv_file_object
    ->rewind();
  $current = $csv_file_object
    ->current();
  $this
    ->assertArrayEquals($row, $current);
}