public function next()
 {
     if ($this->valid()) {
         $this->index++;
     }
     while ($this->valid()) {
         parent::next();
         if ($this->descendTree || $this->reader->depth === $this->stopDepth + 1) {
             break;
         }
     }
 }
 /**
  * @test
  */
 function iterateOverNamedElements()
 {
     $reader = new XMLReaderStub('<r><a>1</a><a>2</a><b>c</b><a>3</a></r>');
     $it = new XMLElementIterator($reader, 'a');
     $this->assertEquals(null, $it->valid());
     $it->rewind();
     $this->assertEquals(true, $it->valid());
     $this->assertEquals('a', $it->current()->getName());
     $it->next();
     $this->assertEquals('a', $it->current()->getName());
     $it->next();
     $this->assertEquals('a', $it->current()->getName());
     $this->assertEquals('3', $it);
     $it->next();
     $this->assertEquals(false, $it->valid());
 }