PhpSpreadsheet/tests/PhpSpreadsheetTests/Worksheet
Tim Gavryutenko 3dcc5ca753
Fix removing last row incorrect behavior
`$highestRow = $this->getHighestDataRow();` was calculated after `$this->getCellCollection()->removeRow($pRow + $r);` - this is the root reason for incorrect rows removal because removing last row will change '$this->getHighestDataRow()' value, but removing row from the middle will not change it. So, removing last row causes incorrect `$highestRow` value that is used for wiping out empty rows from the bottom of the table:
```php
for ($r = 0; $r < $pNumRows; ++$r) {
    $this->getCellCollection()->removeRow($highestRow);
    --$highestRow;
}
```
To prevent this incorrect behavior I've moved highest row calculation before row removal.
But this still doesn't solve another problem when trying remove non existing rows: in this case the code above will remove `$pNumRows` rows from below of the table, e.g. if `$highestRow=4` and `$pNumRows=6`, than rows 4, 3, 2, 1, 0, -1 will be deleted. Obviously, this is not good, that is why I've added `$removedRowsCounter` to fix this issue.
And finally, moved Exception to early if statement to get away from unnecessary 'if-else'.

Fixes #1364
Closes #1365
2020-04-26 11:00:43 +09:00
..
AutoFilter Migrate away from deprecated PHPUnit asserts 2019-07-25 10:15:53 -07:00
AutoFilterTest.php Migrate away from deprecated PHPUnit asserts 2019-07-25 10:15:53 -07:00
ColumnCellIteratorTest.php Allow iterators to go out of bounds with prev() 2018-08-19 14:02:17 +09:00
ColumnDimensionTest.php Add test for PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension 2019-11-17 21:19:50 +01:00
ColumnIteratorTest.php Allow iterators to go out of bounds with prev() 2018-08-19 14:02:17 +09:00
ColumnTest.php Update to PHP-CS-Fixer 2.10 2018-01-28 15:59:38 +09:00
DrawingTest.php Avoid memory exhaustion when cloning worksheet with a drawing 2018-08-05 13:21:01 +09:00
IteratorTest.php Allow iterators to go out of bounds with prev() 2018-08-19 14:02:17 +09:00
RowCellIteratorTest.php Allow iterators to go out of bounds with prev() 2018-08-19 14:02:17 +09:00
RowIteratorTest.php Allow iterators to go out of bounds with prev() 2018-08-19 14:02:17 +09:00
RowTest.php Update to PHP-CS-Fixer 2.10 2018-01-28 15:59:38 +09:00
WorksheetTest.php Fix removing last row incorrect behavior 2020-04-26 11:00:43 +09:00