public function testResolve()
 {
     $documentIds = ['document_1', 'document_2'];
     $resolvedAggregations = ['aggregation_1'];
     $this->request->expects($this->atLeastOnce())->method('getIndex')->willReturn('specific_resolver');
     $this->specificAggregationResolver->expects($this->once())->method('resolve')->with($this->request, $documentIds)->willReturn($resolvedAggregations);
     $this->assertEquals($resolvedAggregations, $this->aggregationResolver->resolve($this->request, $documentIds));
 }
Exemplo n.º 2
0
 /**
  * @param RequestInterface $request
  * @param Table $documentsTable
  * @param array $documents
  * @return array
  */
 private function processAggregations(RequestInterface $request, Table $documentsTable, $documents)
 {
     $aggregations = [];
     $documentIds = $documents ? $this->extractDocumentIds($documents) : $this->getDocumentIds($documentsTable);
     $buckets = $this->aggregationResolver->resolve($request, $documentIds);
     $dataProvider = $this->dataProviderContainer->get($request->getIndex());
     foreach ($buckets as $bucket) {
         $aggregationBuilder = $this->aggregationContainer->get($bucket->getType());
         $aggregations[$bucket->getName()] = $aggregationBuilder->build($dataProvider, $request->getDimensions(), $bucket, $documentsTable);
     }
     return $aggregations;
 }
Exemplo n.º 3
0
 public function testBuildWithoutPassedDocuments()
 {
     $documentIds = [1, 2];
     $tableName = 'table_name';
     $select = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock();
     $select->expects($this->once())->method('from')->with($tableName, TemporaryStorage::FIELD_ENTITY_ID)->willReturnSelf();
     $this->table->expects($this->once())->method('getName')->willReturn($tableName);
     $this->connectionMock->expects($this->once())->method('select')->willReturn($select);
     $this->connectionMock->expects($this->once())->method('fetchCol')->willReturn($documentIds);
     $this->aggregationResolver->expects($this->once())->method('resolve')->with($this->request, $documentIds)->willReturn([]);
     $this->builder->build($this->request, $this->table);
 }