/** * @dataProvider seekChunkChangeDataProvider */ public function testSeekChunkChange($jumpTo, $moreValidElements = true) { $csvContent = $this->getContent(202); $filePath = $this->setUpVirtualFileAndGetPath($csvContent); $csvIterator = new Iterator($filePath, ';'); $csvIterator->rewind(); $csvIterator->seek($jumpTo); $this->assertTrue($csvIterator->valid()); $this->assertEquals(array('col1' => "val1-{$jumpTo}", 'col2' => "val2-{$jumpTo}"), $csvIterator->current()); $this->assertEquals($jumpTo, $csvIterator->key()); $csvIterator->next(); if ($moreValidElements) { $next = $jumpTo + 1; $this->assertTrue($csvIterator->valid()); $this->assertEquals(array('col1' => "val1-{$next}", 'col2' => "val2-{$next}"), $csvIterator->current()); $this->assertEquals($next, $csvIterator->key()); return; } $this->assertFalse($csvIterator->valid()); $csvIterator->rewind(); $this->assertTrue($csvIterator->valid()); $this->assertEquals(array('col1' => "val1-1", 'col2' => "val2-1"), $csvIterator->current()); $this->assertEquals(1, $csvIterator->key()); }