Esempio n. 1
0
 /**
  * @param RequestInterface $request
  * @param Table $documentsTable
  * @return array
  */
 private function processAggregations(RequestInterface $request, Table $documentsTable)
 {
     $aggregations = [];
     $buckets = $request->getAggregation();
     $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;
 }
Esempio n. 2
0
 /**
  * SetUP method
  */
 protected function setUp()
 {
     $helper = new ObjectManager($this);
     $this->entityMetadata = $this->getMockBuilder('Magento\\Framework\\Search\\EntityMetadata')->setMethods(['getEntityId'])->disableOriginalConstructor()->getMock();
     $this->request = $this->getMockBuilder('Magento\\Framework\\Search\\RequestInterface')->setMethods(['getAggregation'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->bucket = $this->getMockBuilder('Magento\\Framework\\Search\\Request\\BucketInterface')->setMethods(['getName'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->select = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $this->bucketBuilder = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Aggregation\\Builder\\BucketInterface')->setMethods(['build'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->aggregationContainer = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Aggregation\\Builder\\Container')->setMethods(['get'])->disableOriginalConstructor()->getMock();
     $this->aggregationContainer->expects($this->any())->method('get')->willReturn($this->bucketBuilder);
     $this->adapter = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->setMethods(['fetchAssoc'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->dataProvider = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Aggregation\\DataProviderInterface')->setMethods(['getDataSet'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->dataProviderContainer = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Aggregation\\DataProviderContainer')->setMethods(['get'])->disableOriginalConstructor()->getMock();
     $this->dataProviderContainer->expects($this->any())->method('get')->willReturn($this->dataProvider);
     $this->resource = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->any())->method('getConnection')->willReturn($this->adapter);
     $this->builder = $helper->getObject('Magento\\Framework\\Search\\Adapter\\Mysql\\Aggregation\\Builder', ['entityMetadata' => $this->entityMetadata, 'dataProviderContainer' => $this->dataProviderContainer, 'resource' => $this->resource, 'aggregationContainer' => $this->aggregationContainer]);
 }