コード例 #1
0
 /**
  * @test
  */
 function iteration()
 {
     $reader = new XMLReaderStub('<r><a>1</a><a>2</a></r>');
     $it = new XMLReaderIterator($reader);
     $this->assertSame(null, $it->valid());
     $it->rewind();
     $this->assertSame(true, $it->valid());
     $node = $it->current();
     $this->assertEquals('r', $node->getName());
     $this->assertEquals('12', (string) $node);
     $it->moveToNextElementByName('a');
     $node = $it->current();
     $this->assertEquals('a', $node->getName());
     $this->assertEquals('1', (string) $node);
     $it->moveToNextElementByName('a');
     $node = $it->current();
     $this->assertEquals('a', $node->getName());
     $this->assertEquals('2', (string) $node);
     $it->next();
     $it->next();
     $this->assertEquals(XMLReader::END_ELEMENT, $reader->nodeType);
     $this->assertEquals('a', $it->current()->getName());
     $it->next();
     $it->next();
     $this->assertEquals(false, $it->valid());
 }
コード例 #2
0
 public function next()
 {
     if (self::$goToNext) {
         parent::next();
     }
     self::$goToNext = true;
 }
コード例 #3
0
 public function next()
 {
     if (parent::valid()) {
         $this->index++;
     }
     parent::next();
     $this->ensureCurrentElementState();
 }
コード例 #4
0
 public function rewind()
 {
     parent::next();
     parent::rewind();
 }