Skip to content

Commit

Permalink
Cover Parser::setEscape()
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 6, 2023
1 parent 8606c5e commit 42a8746
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/unit/ParserTest.php
Expand Up @@ -68,6 +68,7 @@ public static function provider(): array
true,
null,
null,
null,
],

'CSV file with header; schema for subset of fields' => [
Expand All @@ -77,6 +78,7 @@ public static function provider(): array
true,
null,
null,
null,
],

'CSV file without header; schema for all fields' => [
Expand All @@ -86,6 +88,7 @@ public static function provider(): array
false,
null,
null,
null,
],

'CSV file without header; schema for subset of fields' => [
Expand All @@ -95,6 +98,7 @@ public static function provider(): array
false,
null,
null,
null,
],

'CSV file with enclosed values (default enclosure)' => [
Expand All @@ -104,6 +108,7 @@ public static function provider(): array
false,
null,
null,
null,
],

'CSV file with enclosed values (non-default enclosure)' => [
Expand All @@ -113,6 +118,7 @@ public static function provider(): array
false,
null,
'\'',
null,
],

'CSV file with non-default separator' => [
Expand All @@ -122,6 +128,7 @@ public static function provider(): array
false,
';',
null,
null,
],

'CSV file with escaped values (default escape)' => [
Expand Down Expand Up @@ -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;

Expand All @@ -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();
}
Expand Down

0 comments on commit 42a8746

Please sign in to comment.