mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 00:36:38 +00:00
@@ -418,7 +418,7 @@ class parseCSV {
|
||||
$file = &$this->file;
|
||||
}
|
||||
|
||||
$mode = $append ? 'at' : 'wt';
|
||||
$mode = $append ? 'ab' : 'wb';
|
||||
$is_php = preg_match('/\.php$/i', $file) ? true : false;
|
||||
|
||||
return $this->_wfile($file, $this->unparse($data, $fields, $append, $is_php), $mode);
|
||||
|
||||
@@ -32,6 +32,18 @@ class SaveTest extends PHPUnit\Framework\TestCase {
|
||||
$this->saveAndCompare($expected);
|
||||
}
|
||||
|
||||
public function testSaveWithDosLineEnding() {
|
||||
$this->csv->linefeed = "\r\n";
|
||||
$expected = "SMS\r\n0444\r\n5555\r\n";
|
||||
$this->saveAndCompare($expected);
|
||||
}
|
||||
|
||||
public function testSaveWithUnixLineEnding() {
|
||||
$this->csv->linefeed = "\n";
|
||||
$expected = "SMS\n0444\n5555\n";
|
||||
$this->saveAndCompare($expected);
|
||||
}
|
||||
|
||||
public function testAllQuotes() {
|
||||
$this->csv->enclose_all = true;
|
||||
$expected = "\"SMS\"\r\"0444\"\r\"5555\"\r";
|
||||
|
||||
Reference in New Issue
Block a user