getQuery() public method

public getQuery ( )
 function it_hydrates_a_result_record(Builder $builder, Query $query, ProductInterface $product, Association $association, AssociationType $associationType, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, DocumentManager $documentManager, \Doctrine\ODM\MongoDB\Mapping\ClassMetadata $metadata, Collection $collection, ArrayIterator $arrayIterator)
 {
     $options = ['locale_code' => 'en_US', 'scope_code' => 'print', 'current_group_id' => null, 'attributes_configuration' => [], 'association_type_id' => 1, 'current_product' => $product];
     $builder->getQuery()->willReturn($query);
     $builder->hydrate(false)->willReturn($builder);
     $associatedProduct1->getId()->willReturn('550ae6b98ead0ed7778b46bb');
     $associatedProduct2->getId()->willReturn('550ae6b98abd0ec8778b46bb');
     $product->getAssociations()->willReturn([$association]);
     $association->getAssociationType()->willReturn($associationType);
     $associationType->getId()->willReturn(1);
     $association->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]);
     $queryDefinition = ['type' => 1, 'sort' => ['normalizedData.is_associated' => -1, '_id' => 1], 'limit' => 10, 'skip' => 0, 'query' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb'])]], 'newObj' => []];
     $query->getQuery()->willReturn($queryDefinition);
     $query->getDocumentManager()->willReturn($documentManager);
     $documentManager->getDocumentCollection(Argument::any())->willReturn($collection);
     $documentManager->getClassMetadata(Argument::any())->willReturn($metadata);
     $metadata->getFieldNames()->willReturn(['id', 'created', 'updated', 'locale', 'scope', 'values', 'indexedValues', 'indexedValuesOutdated', 'family', 'familyId', 'categories', 'categoryIds', 'enabled', 'groups', 'groupIds', 'associations', 'completenesses', 'normalizedData']);
     $pipeline = [['$match' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb'])]]], ['$project' => ['id' => 1, 'created' => 1, 'updated' => 1, 'locale' => 1, 'scope' => 1, 'values' => 1, 'indexedValues' => 1, 'indexedValuesOutdated' => 1, 'family' => 1, 'familyId' => 1, 'categories' => 1, 'categoryIds' => 1, 'enabled' => 1, 'groups' => 1, 'groupIds' => 1, 'associations' => 1, 'completenesses' => 1, 'normalizedData' => 1, 'is_associated' => ['$cond' => [['$or' => [['$eq' => ['$_id', \MongoId::__set_state(['$id' => '550ae6b98ead0ed7778b46bb'])]], ['$eq' => ['$_id', \MongoId::__set_state(['$id' => '550ae6b98abd0ec8778b46bb'])]]]], 1, 0]]]], ['$sort' => ['is_associated' => -1]], ['$skip' => 0], ['$limit' => 10]];
     $collection->aggregate($pipeline)->willReturn($arrayIterator);
     $fixture = ['_id' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb']), 'normalizedData' => [], 'sku' => ['attribute' => ['code' => 'sku', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => null, 'scope' => null, 'value' => 'mysku'], 'name' => ['attribute' => ['code' => 'name', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => null], 'desc' => ['attribute' => ['code' => 'desc', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => 'print'], 'is_associated' => 1];
     $arrayIterator->toArray()->willReturn([$fixture]);
     $rows = $this->hydrate($builder, $options);
     $rows->shouldHaveCount(1);
     $firstResult = $rows[0];
     $firstResult->shouldBeAnInstanceOf('\\Oro\\Bundle\\DataGridBundle\\Datasource\\ResultRecord');
 }
 /**
  * Give a cursor and create it if necessary
  *
  * @return CursorMongoDB
  */
 protected function getCursor()
 {
     if (null === $this->cursor) {
         $this->cursor = $this->queryBuilder->getQuery()->execute();
         if (null !== $this->batchSize) {
             $this->cursor->batchSize($this->batchSize);
         }
         // MongoDB Cursor are not positioned on first element (whereas ArrayIterator is)
         // as long as getNext() hasn't be called
         $this->cursor->getNext();
     }
     return $this->cursor;
 }
 function it_creates_a_cursor(Builder $queryBuilder, Query $query, Cursor $cursor)
 {
     $queryBuilder->getQuery()->shouldBeCalled()->willReturn($query);
     $query->execute()->shouldBeCalled()->willReturn($cursor);
     $cursor = $this->createCursor($queryBuilder);
     $cursor->shouldBeAnInstanceOf('Akeneo\\Component\\StorageUtils\\Cursor\\CursorInterface');
 }
 function it_hydrates_a_result_record(Builder $builder, Query $query)
 {
     $options = ['locale_code' => 'en_US', 'scope_code' => 'print', 'current_group_id' => null, 'attributes_configuration' => [], 'association_type_id' => null, 'current_product' => null];
     $builder->getQuery()->willReturn($query);
     $builder->hydrate(false)->willReturn($builder);
     $query->execute()->willReturn([]);
     $this->hydrate($builder, $options);
 }
 /**
  * Returns the document class from the query
  *
  * @return string class name
  */
 private function getDocumentClassName()
 {
     // find our class name
     $documentName = $this->builder->getQuery()->getClass()->getName();
     if (!class_exists($documentName)) {
         throw new \LogicException('Could not determine class name from RQL query.');
     }
     return $documentName;
 }
 protected function initTestList()
 {
     $this->queryBuilder->sort('date', 'DESC');
     $this->listCount = $this->queryBuilder->getQuery()->execute()->count();
     $this->initPagenation();
     if ($this->listCount > 0) {
         $this->queryBuilder->field('userId')->equals('');
         $this->list = $this->queryBuilder = $this->queryBuilder->getQuery()->execute();
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getEntities()
 {
     return array_values($this->queryBuilder->getQuery()->execute()->toArray());
 }
 function let(Builder $queryBuilder, Query $query, Cursor $cursor)
 {
     $queryBuilder->getQuery()->willReturn($query);
     $query->execute()->willReturn($cursor);
     $this->beConstructedWith($queryBuilder);
 }
 /**
  * Get the number of products according to the query
  *
  * @param Builder $queryBuilder  the query builder
  * @param array   $associatedIds the ids of the products that are associated
  * @param array   $rawQuery      the query parameters
  *
  * @return int
  */
 protected function countProducts(Builder $queryBuilder, array $associatedIds, array $rawQuery)
 {
     $queryBuilder->count();
     $queryBuilder->setQueryArray($rawQuery);
     $queryBuilder->limit(0);
     $queryBuilder->skip(0);
     $count = $queryBuilder->getQuery()->execute() - count($associatedIds);
     return max($count, 0);
 }
 /**
  * @see Zend\Paginator\Adapter::count
  */
 public function count()
 {
     return $this->queryBuilder->getQuery()->count();
 }