PhpSpreadsheet/tests/PhpSpreadsheetTests/Worksheet/IteratorTest.php
Dalibor Karlović 5e090d1af0
Allow iterators to go out of bounds with prev()
Iterators prev() behavior is now consistent with next(), meaning
that it can go out of bounds and it must be validated with valid()
before using it.

Fixes #587
Fixes #627
2018-08-19 14:02:17 +09:00

29 lines
824 B
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Iterator;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PHPUnit\Framework\TestCase;
class IteratorTest extends TestCase
{
public function testIteratorFullRange()
{
$spreadsheet = new Spreadsheet();
$spreadsheet->createSheet();
$spreadsheet->createSheet();
$iterator = new Iterator($spreadsheet);
$columnIndexResult = 0;
self::assertEquals($columnIndexResult, $iterator->key());
foreach ($iterator as $key => $column) {
self::assertEquals($columnIndexResult++, $key);
self::assertInstanceOf(Worksheet::class, $column);
}
self::assertSame(3, $columnIndexResult);
}
}