Fix CSV reader when last line is empty

If the last line was empty, it would create an infinite loop...
This commit is contained in:
Adrien Loison committed 2015-07-29 10:17:51 -07:00
1 parent e3f7ecfa64
commit 8a3b895afc
4 files changed
+67 -12

No files matched your search

+16 -2
View File
@@ -115,11 +115,25 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @return array
*/
public function dataProviderForTestReadShouldSkipEmptyLines()
{
return [
['csv_with_empty_line.csv'],
['csv_with_empty_last_line.csv'],
];
}
/**
* @dataProvider dataProviderForTestReadShouldSkipEmptyLines
*
* @param string $fileName
* @return void
*/
public function testReadShouldSkipEmptyLines()
public function testReadShouldSkipEmptyLines($fileName)
{
$allRows = $this->getAllRowsForFile('csv_with_empty_line.csv');
$allRows = $this->getAllRowsForFile($fileName);
$expectedRows = [
['csv--11', 'csv--12', 'csv--13'],