diff --git a/src/ColumnConsistencyTest.php b/src/ColumnConsistencyTest.php index 01914126..4ece5bfe 100644 --- a/src/ColumnConsistencyTest.php +++ b/src/ColumnConsistencyTest.php @@ -31,8 +31,8 @@ protected function setUp(): void protected function tearDown(): void { $csv = new SplFileObject(__DIR__.'/../test_files/foo.csv', 'w'); - $csv->setCsvControl(); - $csv->fputcsv(['john', 'doe', 'john.doe@example.com'], ',', '"'); + $csv->setCsvControl(escape: '\\'); + $csv->fputcsv(fields: ['john', 'doe', 'john.doe@example.com']); unset($this->csv); } diff --git a/src/EscapeFormulaTest.php b/src/EscapeFormulaTest.php index 025d0901..e112581e 100644 --- a/src/EscapeFormulaTest.php +++ b/src/EscapeFormulaTest.php @@ -63,7 +63,7 @@ public function testFormatterOnWriter(): void $record = ['2', '2017-07-25', 'Important Client', '=2+5', 240, "\ttab", "\rcr", null]; $expected = "2,2017-07-25,\"Important Client\",'=2+5,240,\"'\ttab\",\"'\rcr\",\n"; $csv = Writer::createFromFileObject(new SplTempFileObject()); - $csv->addFormatter(new EscapeFormula()); + $csv->addFormatter((new EscapeFormula())->escapeRecord(...)); $csv->insertOne($record); self::assertStringContainsString($expected, $csv->toString()); } diff --git a/src/InfoTest.php b/src/InfoTest.php index 02c57bd4..af6cb339 100644 --- a/src/InfoTest.php +++ b/src/InfoTest.php @@ -64,9 +64,9 @@ public function testDetectDelimiterWithNoValidDelimiter(): void public function testDetectDelimiterListWithInconsistentCSV(): void { $data = new SplTempFileObject(); - $data->setCsvControl(';'); + $data->setCsvControl(separator: ';', escape: '\\'); $data->fputcsv(['toto', 'tata', 'tutu']); - $data->setCsvControl('|'); + $data->setCsvControl('|', escape: '\\'); $data->fputcsv(['toto', 'tata', 'tutu']); $data->fputcsv(['toto', 'tata', 'tutu']); $data->fputcsv(['toto', 'tata', 'tutu']); diff --git a/src/ReaderTest.php b/src/ReaderTest.php index b8706e2b..e92e4595 100644 --- a/src/ReaderTest.php +++ b/src/ReaderTest.php @@ -38,8 +38,9 @@ final class ReaderTest extends TabularDataReaderTestCase protected function setUp(): void { $tmp = new SplTempFileObject(); + $tmp->setCsvControl(escape: '\\'); foreach ($this->expected as $row) { - $tmp->fputcsv($row); + $tmp->fputcsv($row, escape: ''); } $this->csv = Reader::createFromFileObject($tmp); @@ -156,6 +157,7 @@ public function testCall(): void ]; $file = new SplTempFileObject(); + $file->setCsvControl(escape: '\\'); foreach ($raw as $row) { $file->fputcsv($row); } @@ -213,7 +215,7 @@ public function testStripBOM(array $record, string $expected_bom, string $expect { /** @var resource $fp */ $fp = fopen('php://temp', 'r+'); - fputcsv($fp, $record); + fputcsv($fp, $record, escape: ''); $csv = Reader::createFromStream($fp); self::assertSame($expected_bom, $csv->getInputBOM()); foreach ($csv as $row) { @@ -274,7 +276,7 @@ public function testDisablingBOMStripping(): void $expected_record = [Bom::Utf16Le->value.'john', 'doe', 'john.doe@example.com']; /** @var resource $fp */ $fp = fopen('php://temp', 'r+'); - fputcsv($fp, $expected_record); + fputcsv($fp, $expected_record, escape: ''); $csv = Reader::createFromStream($fp); $csv->includeInputBOM(); self::assertSame(Bom::Utf16Le->value, $csv->getInputBOM()); @@ -333,7 +335,7 @@ public function testGetHeaderThrowsExceptionWithStreamObject(): void /** @var resource $tmp */ $tmp = fopen('php://temp', 'r+'); foreach ($this->expected as $row) { - fputcsv($tmp, $row); + fputcsv($tmp, $row, escape: ''); } $csv = Reader::createFromStream($tmp); @@ -363,6 +365,7 @@ public function testJsonSerialize(): void ]; $tmp = new SplTempFileObject(); + $tmp->setCsvControl(escape: '\\'); foreach ($expected as $row) { $tmp->fputcsv($row); } diff --git a/src/ResultSetTest.php b/src/ResultSetTest.php index d968d00a..18a1ed40 100644 --- a/src/ResultSetTest.php +++ b/src/ResultSetTest.php @@ -35,6 +35,7 @@ final class ResultSetTest extends TabularDataReaderTestCase protected function setUp(): void { $tmp = new SplTempFileObject(); + $tmp->setCsvControl(escape: '\\'); foreach ($this->expected as $row) { $tmp->fputcsv($row); } @@ -173,6 +174,7 @@ public function testFetchAssocWithRowIndex(): void ]; $tmp = new SplTempFileObject(); + $tmp->setCsvControl(escape: '\\'); foreach ($arr as $row) { $tmp->fputcsv($row); } @@ -203,6 +205,7 @@ public function testFetchColumnInconsistentColumnCSV(): void ]; $file = new SplTempFileObject(); + $file->setCsvControl(escape: '\\'); foreach ($raw as $row) { $file->fputcsv($row); } @@ -220,6 +223,7 @@ public function testFetchColumnEmptyCol(): void ]; $file = new SplTempFileObject(); + $file->setCsvControl(escape: '\\'); foreach ($raw as $row) { $file->fputcsv($row); } @@ -312,6 +316,7 @@ public function testJsonSerialize(): void ]; $tmp = new SplTempFileObject(); + $tmp->setCsvControl(escape: '\\'); foreach ($expected as $row) { $tmp->fputcsv($row); } diff --git a/src/StatementTest.php b/src/StatementTest.php index 1313f736..0dbaf513 100644 --- a/src/StatementTest.php +++ b/src/StatementTest.php @@ -38,6 +38,7 @@ final class StatementTest extends TestCase protected function setUp(): void { $tmp = new SplTempFileObject(); + $tmp->setCsvControl(escape: '\\'); foreach ($this->expected as $row) { $tmp->fputcsv($row); } diff --git a/src/StreamTest.php b/src/StreamTest.php index 5b21d5e1..0d7298b6 100644 --- a/src/StreamTest.php +++ b/src/StreamTest.php @@ -90,7 +90,7 @@ public function testCreateStreamFromPathWithContext(): void ]; foreach ($expected as $row) { - fputcsv($fp, $row); + fputcsv($fp, $row, escape: ''); } $stream = Stream::createFromPath( @@ -143,7 +143,7 @@ public function testFSeekThrowsExceptionOnNonSeakableResource(): void $this->expectException(UnavailableFeature::class); $stream = Stream::createFromResource(STDOUT); - $stream->fputcsv(['foo', 'bar']); + $stream->fputcsv(['foo', 'bar'], escape: ''); $stream->fseek(-1); } diff --git a/src/WriterTest.php b/src/WriterTest.php index f29d185f..4a5047c6 100644 --- a/src/WriterTest.php +++ b/src/WriterTest.php @@ -38,8 +38,8 @@ protected function setUp(): void protected function tearDown(): void { $csv = new SplFileObject(__DIR__.'/../test_files/foo.csv', 'w'); - $csv->setCsvControl(); - $csv->fputcsv(['john', 'doe', 'john.doe@example.com'], ',', '"'); + $csv->setCsvControl(escape: ''); + $csv->fputcsv(['john', 'doe', 'john.doe@example.com']); unset($this->csv); }