getIterator() public method

If the query type is not expected to return an Iterator, BadMethodCallException will be thrown before executing the query. Otherwise, the query will be executed and UnexpectedValueException will be thrown if {@link Query::execute()} does not return an Iterator.
See also: http://php.net/manual/en/iteratoraggregate.getiterator.php
public getIterator ( ) : Doctrine\MongoDB\Iterator
return Doctrine\MongoDB\Iterator
Ejemplo n.º 1
0
 /**
  * @dataProvider provideQueryTypesThatDoReturnAnIterator
  * @expectedException UnexpectedValueException
  */
 public function testGetIteratorShouldThrowExceptionAfterExecutingForTypesThatShouldReturnAnIteratorButDoNot($type, $method)
 {
     $collection = $this->getMockCollection();
     $collection->expects($this->once())->method($method)->will($this->returnValue(null));
     // Create a query array with any fields that may be expected to exist
     $queryArray = array('type' => $type, 'query' => array(), 'group' => array('keys' => array(), 'initial' => array(), 'reduce' => '', 'options' => array()), 'mapReduce' => array('map' => '', 'reduce' => '', 'out' => '', 'options' => array()), 'geoNear' => array('near' => array(), 'options' => array()), 'distinct' => 0);
     $query = new Query($collection, $queryArray, array());
     $query->getIterator();
 }