You are here

public function CsvParserTest::provider in Feeds 8.3

Data provider for testAlternateLineEnding().

File

tests/src/Unit/Component/CsvParserTest.php, line 52

Class

CsvParserTest
@coversDefaultClass \Drupal\feeds\Component\CsvParser @group feeds

Namespace

Drupal\Tests\feeds\Unit\Component

Code

public function provider() {
  $expected = [
    [
      'Header A',
      'Header B',
      'Header C',
    ],
    [
      '"1"',
      '"2"',
      '"3"',
    ],
    [
      'qu"ote',
      'qu"ote',
      'qu"ote',
    ],
    [
      "\r\n\r\nline1",
      "\r\n\r\nline2",
      "\r\n\r\nline3",
    ],
    [
      "new\r\nline 1",
      "new\r\nline 2",
      "new\r\nline 3",
    ],
    [
      "\r\n\r\nline1\r\n\r\n",
      "\r\n\r\nline2\r\n\r\n",
      "\r\n\r\nline3\r\n\r\n",
    ],
    [
      'Col A',
      'Col B',
      'Col, C',
    ],
  ];
  $unix = $expected;
  array_walk_recursive($unix, function (&$item, $key) {
    $item = str_replace("\r\n", "\n", $item);
  });
  $mac = $expected;
  array_walk_recursive($mac, function (&$item, $key) {
    $item = str_replace("\r\n", "\r", $item);
  });
  return [
    [
      $expected,
      "\r\n",
    ],
    [
      $unix,
      "\n",
    ],
    [
      $mac,
      "\r",
    ],
  ];
}