You are here

public function CsvParserFeedFormTest::testDelimiterSetting in Feeds 8.3

Tests importing a feed using various delimiters.

@dataProvider delimiterDataProvider

Parameters

string $delimiter: The delimiter to test.

string $csv_file: The file to import.

File

tests/src/Functional/Feeds/Parser/Form/CsvParserFeedFormTest.php, line 75

Class

CsvParserFeedFormTest
@coversDefaultClass \Drupal\feeds\Feeds\Parser\Form\CsvParserFeedForm @group feeds

Namespace

Drupal\Tests\feeds\Functional\Feeds\Parser\Form

Code

public function testDelimiterSetting($delimiter, $csv_file) {

  // Create feed and import.
  $edit = [
    'title[0][value]' => $this
      ->randomMachineName(),
    'files[plugin_fetcher_source]' => \Drupal::service('file_system')
      ->realpath($this
      ->resourcesPath() . '/csv/' . $csv_file),
    'plugin[parser][delimiter]' => $delimiter,
  ];
  $this
    ->drupalPostForm('feed/add/' . $this->feedType
    ->id(), $edit, t('Save and import'));

  // Load feed.
  $feed = Feed::load(1);

  // Assert that 9 nodes have been created.
  static::assertEquals(9, $feed
    ->getItemCount());
  $this
    ->assertNodeCount(9);
}