From 42a87460f3cff47ee0890d034ceecf2071b7c3d2 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 6 Apr 2023 09:12:32 +0200 Subject: [PATCH] Cover Parser::setEscape() --- tests/unit/ParserTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/unit/ParserTest.php b/tests/unit/ParserTest.php index 1e3dc12..e241d34 100644 --- a/tests/unit/ParserTest.php +++ b/tests/unit/ParserTest.php @@ -68,6 +68,7 @@ public static function provider(): array true, null, null, + null, ], 'CSV file with header; schema for subset of fields' => [ @@ -77,6 +78,7 @@ public static function provider(): array true, null, null, + null, ], 'CSV file without header; schema for all fields' => [ @@ -86,6 +88,7 @@ public static function provider(): array false, null, null, + null, ], 'CSV file without header; schema for subset of fields' => [ @@ -95,6 +98,7 @@ public static function provider(): array false, null, null, + null, ], 'CSV file with enclosed values (default enclosure)' => [ @@ -104,6 +108,7 @@ public static function provider(): array false, null, null, + null, ], 'CSV file with enclosed values (non-default enclosure)' => [ @@ -113,6 +118,7 @@ public static function provider(): array false, null, '\'', + null, ], 'CSV file with non-default separator' => [ @@ -122,6 +128,7 @@ public static function provider(): array false, ';', null, + null, ], 'CSV file with escaped values (default escape)' => [ @@ -153,12 +160,13 @@ public static function provider(): array false, null, null, + '"', ], ]; } #[DataProvider('provider')] - public function test_Parses_CSV_file_according_to_schema(array $expected, Schema $schema, string $filename, bool $ignoreFirstLine, ?string $separator, ?string $enclosure): void + public function test_Parses_CSV_file_according_to_schema(array $expected, Schema $schema, string $filename, bool $ignoreFirstLine, ?string $separator, ?string $enclosure, ?string $escape): void { $parser = new Parser; @@ -170,6 +178,10 @@ public function test_Parses_CSV_file_according_to_schema(array $expected, Schema $parser->setEnclosure($enclosure); } + if ($escape !== null) { + $parser->setEscape($escape); + } + if ($ignoreFirstLine) { $parser->ignoreFirstLine(); }