/**
  * Returns the next persistent object in the result set.
  *
  * The next object is set to the current object of the iterator.
  * Returns null and sets the current object to null if there
  * are no more results in the result set.
  *
  * @return object
  */
 public function next()
 {
     $object = parent::next();
     if ($object !== null) {
         $identity = null;
         if (!$this->options->refetch) {
             $class = get_class($object);
             $state = $object->getState();
             $identity = $this->idMap->getIdentity($class, $state[$this->def->idProperty->propertyName]);
         }
         if ($identity !== null) {
             $this->object = $identity;
         } else {
             $this->idMap->setIdentity($object);
         }
     }
     return $this->object;
 }
 public function testValidManyResults()
 {
     $q = $this->session->createFindQuery('PersistentTestObject');
     $q->where($q->expr->gt($this->db->quoteIdentifier('id'), 2));
     $stmt = $q->prepare();
     $stmt->execute();
     $it = new ezcPersistentFindIterator($stmt, $this->manager->fetchDefinition('PersistentTestObject'));
     $object = $it->next();
     // check that the data is correct
     $this->assertEquals('Ukraine', $object->varchar);
     $this->assertEquals(47732079, (int) $object->integer);
     $this->assertEquals(603.7, (double) $object->decimal);
     $this->assertEquals('Ukraine has a long coastline to the black see.', $object->text);
     $object = $it->next();
     $this->assertEquals('Germany', $object->varchar);
     $this->assertEquals(82443000, (int) $object->integer);
     $this->assertEquals(357.02, (double) $object->decimal);
     $this->assertEquals('Home of the lederhosen!.', $object->text);
     // check that there are no more results
     $this->assertEquals(null, $it->next());
 }