Skip to content

Commit

Permalink
Added a test for issue #177: Saving data with commas
Browse files Browse the repository at this point in the history
  • Loading branch information
gogowitsch committed Dec 26, 2022
1 parent 2d6236c commit 6648dc9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/methods/SaveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ public function testSaveWithNewHeader() {
$this->saveAndCompare($expected);
}

public function testSaveWithDelimiterOfComma() {
$this->csv = new Csv();
$this->csv->heading = false;
$this->csv->delimiter = ",";
$this->csv->linefeed = "\n";
$this->csv->data = [
[
'3,21',
'Twitter',
'Monsieur',
'eat more vegan food',
],
[
'"9,72"',
'newsletter',
'Madame',
'"free travel"',
],
];

// Yep, these double quotes are what Excel and Open Office understand.
$expected =
'"3,21",Twitter,Monsieur,eat more vegan food' . "\n" .
'"""9,72""",newsletter,Madame,"""free travel"""' . "\n";
$actual = $this->csv->unparse();
self::assertSame($expected, $actual);
}

public function testSaveWithoutHeader() {
$this->csv->linefeed = "\n";
$this->csv->heading = false;
Expand Down

0 comments on commit 6648dc9

Please sign in to comment.