ODS Reader should support num-rows-repeated for non empty rows

This commit is contained in:
Adrien Loison 2016-10-17 10:46:47 -07:00
parent 5ef5647558
commit 5f6436cc70
3 changed files with 17 additions and 8 deletions

View File

@ -131,13 +131,10 @@ class RowIterator implements IteratorInterface
/**
* Returns whether we need data for the next row to be processed.
* We don't need to read data if:
* we have already read at least one row
* AND
* we need to preserve empty rows
* AND
* the last row that was read is not the row that need to be processed
* (i.e. if we need to return empty rows)
* We DO need to read data if:
* - we have not read any rows yet
* OR
* - the next row to be processed immediately follows the last read row
*
* @return bool Whether we need data for the next row to be processed.
*/
@ -147,7 +144,6 @@ class RowIterator implements IteratorInterface
return (
!$hasReadAtLeastOneRow ||
!$this->shouldPreserveEmptyRows ||
$this->lastRowIndexProcessed === $this->nextRowIndexToBeProcessed - 1
);
}

View File

@ -78,6 +78,19 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals([['foo']], $allRows);
}
/**
* @return void
*/
public function testReadShouldSupportNumberRowsRepeated()
{
$allRows = $this->getAllRowsForFile('sheet_with_number_rows_repeated.ods');
$expectedRows = [
['foo', 10.43],
['foo', 10.43],
];
$this->assertEquals($expectedRows, $allRows);
}
/**
* @return void
*/