/**
  * @test
  */
 public function unionShouldBeCorrectForObjectsCollections()
 {
     $collection1 = new IteratorCollection(new \ArrayIterator(array(new Bird(), new Bird())));
     $collection2 = new IteratorCollection(new \ArrayIterator(array(new Bullfinch())));
     assertEquals(array(new Bird(), new Bird(), new Bullfinch()), $collection1->union($collection2)->toArray());
 }
Exemplo n.º 2
0
 /**
  * @{inheritDoc}
  */
 public function getIterator()
 {
     if ($this->queryBuilder) {
         return new CollectionMapIterator($this->queryBuilder->getQuery()->iterate(), function ($row) {
             $entity = $row[0];
             if ($this->detaching) {
                 $this->queryBuilder->getEntityManager()->detach($entity);
             }
             return $entity;
         });
     } else {
         return parent::getIterator();
     }
 }