You are here

protected function CSVExportViewsDataExportExporterTests::testNewLineOptions in Views data export 7.4

Test the newline replacement option.

File

tests/exporter_tests/csv.test, line 188

Class

CSVExportViewsDataExportExporterTests

Code

protected function testNewLineOptions() {

  // Write a dataset with newlines in the field values.
  $dataSet = array(
    array(
      'name' => 'John, the one with
cool hair',
      'age' => 25,
      'job' => 'Singer',
      'created' => gmmktime(0, 0, 0, 1, 1, 2000),
    ),
  );
  $result = $this
    ->executeFullWrite($this
    ->getExporter(array(
    'separator' => ",",
    'quote' => true,
    'replace_newlines' => true,
    'newline_replacement' => 'NEWLINE',
  )), $dataSet, 0, array(
    'name' => 'Name',
    'age' => 'Age',
    'job' => 'Job',
    'created' => 'Created',
  ));
  $expected = '"John, the one withNEWLINEcool hair","25","Singer","946684800"
';
  $this
    ->logVerboseResult($result, 'Actual result');
  $this
    ->logVerboseResult($expected, 'Expected result');
  $this
    ->assertEqual($result, $expected, 'The CSV output is as expected.');
}