public function testApiRemove_ThrowsException_OnInvalidIterator() { $this->setExpectedException(OutOfBoundsException::class); for ($this->iterator->rewind(); $this->iterator->valid(); $this->iterator->next()) { } $this->iterator->remove(); }
public function testIteration() { $result = null; for ($i = 0, $this->iterator->rewind(); $this->iterator->valid(); ++$i, $this->iterator->next()) { if ($i !== $this->iterator->key()) { $this->fail('Got invalid key from iterator.'); } $result .= $this->iterator->current(); } $this->assertSame($this->initialString, $result); $this->iterator->prev(); $this->assertTrue($this->iterator->valid()); $this->assertSame($this->buffer->length() - 1, $this->iterator->key()); }