mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Added a test for issue #177: Saving data with commas
This commit is contained in:
@@ -56,6 +56,34 @@ class SaveTest extends TestCase {
|
|||||||
$this->saveAndCompare($expected);
|
$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() {
|
public function testSaveWithoutHeader() {
|
||||||
$this->csv->linefeed = "\n";
|
$this->csv->linefeed = "\n";
|
||||||
$this->csv->heading = false;
|
$this->csv->heading = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user