protected function CSVExportViewsDataExportExporterTests::testSeparatorOptions in Views data export 7.4
Test out the exporter separator option with a few different characters.
File
- tests/
exporter_tests/ csv.test, line 86
Class
Code
protected function testSeparatorOptions() {
// Write the dataset, comma separated.
$result = $this
->executeFullWrite($this
->getExporter(array(
'separator' => ',',
)), $this
->dataSet(), 0, array(
'name' => 'Name',
'age' => 'Age',
'job' => 'Job',
'created' => 'Created',
));
$expected = '"John","25","Singer","946684800"
"George","27","Singer","946771200"
"Ringo","28","Drummer","946708230"
"Paul","26","Songwriter","946706400"
"Meredith","30","Speaker","946708210"
';
$this
->logVerboseResult($result, 'Actual result');
$this
->logVerboseResult($expected, 'Expected result');
$this
->assertEqual($result, $expected, 'The CSV output is as expected.');
// Write the dataset, tab separated.
$result = $this
->executeFullWrite($this
->getExporter(array(
'separator' => "\t",
)), $this
->dataSet(), 0, array(
'name' => 'Name',
'age' => 'Age',
'job' => 'Job',
'created' => 'Created',
));
$expected = '"John"' . "\t" . '"25"' . "\t" . '"Singer"' . "\t" . '"946684800"
"George"' . "\t" . '"27"' . "\t" . '"Singer"' . "\t" . '"946771200"
"Ringo"' . "\t" . '"28"' . "\t" . '"Drummer"' . "\t" . '"946708230"
"Paul"' . "\t" . '"26"' . "\t" . '"Songwriter"' . "\t" . '"946706400"
"Meredith"' . "\t" . '"30"' . "\t" . '"Speaker"' . "\t" . '"946708210"
';
$this
->logVerboseResult($result, 'Actual result');
$this
->logVerboseResult($expected, 'Expected result');
$this
->assertEqual($result, $expected, 'The CSV output is as expected.');
}