예제 #1
0
 public function testApiRemove_ThrowsException_OnInvalidIterator()
 {
     $this->setExpectedException(OutOfBoundsException::class);
     for ($this->iterator->rewind(); $this->iterator->valid(); $this->iterator->next()) {
     }
     $this->iterator->remove();
 }
예제 #2
0
 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());
 }