diff --git a/src/CsvFile.php b/src/CsvFile.php index ee9892e..d0a0ecc 100644 --- a/src/CsvFile.php +++ b/src/CsvFile.php @@ -405,12 +405,12 @@ public function validateLineBreak() Exception::INVALID_PARAM_STR ); } - if (in_array($lineBreak, ["\r\n", "\n"])) { + if (in_array($lineBreak, ["\r\n", "\n", "\r"])) { return $lineBreak; } throw new InvalidArgumentException( - "Invalid line break. Please use unix \\n or win \\r\\n line breaks.", + "Invalid line break. Please use unix \\n or win \\r\\n or Mac \\r line breaks.", Exception::INVALID_PARAM, null, Exception::INVALID_PARAM_STR diff --git a/tests/CsvFileTest.php b/tests/CsvFileTest.php index 050dab3..7fec707 100644 --- a/tests/CsvFileTest.php +++ b/tests/CsvFileTest.php @@ -172,24 +172,7 @@ public function validLineBreaksData() ['test-input.win.csv', "\r\n", '\r\n'], ['escaping.csv', "\n", '\n'], ['just-header.csv', "\n", '\n'], // default - ]; - } - - /** - * @expectedException \Keboola\Csv\InvalidArgumentException - * @dataProvider invalidLineBreaksData - * @param string $file - */ - public function testInvalidLineBreak($file) - { - $csvFile = new CsvFile(__DIR__ . '/data/' . $file); - $csvFile->validateLineBreak(); - } - - public function invalidLineBreaksData() - { - return [ - ['test-input.mac.csv'], + ['test-input.mac.csv', "\r", '\r'] ]; }