76 $this->connectionManager = $this->getMockBuilder(\
Magento\Elasticsearch\SearchAdapter\ConnectionManager::class)
77 ->setMethods([
'getConnection'])
78 ->disableOriginalConstructor()
80 $this->fieldMapper = $this->getMockBuilder(\
Magento\Elasticsearch\Model\
Adapter\FieldMapperInterface::class)
81 ->disableOriginalConstructor()
83 $this->clientConfig = $this->getMockBuilder(\
Magento\Elasticsearch\Model\Config::class)
88 ->disableOriginalConstructor()
90 $this->storeManager = $this->getMockBuilder(\
Magento\Store\Model\StoreManagerInterface::class)
91 ->disableOriginalConstructor()
93 $this->customerSession = $this->getMockBuilder(\
Magento\Customer\Model\Session::class)
94 ->setMethods([
'getCustomerGroupId'])
95 ->disableOriginalConstructor()
97 $this->customerSession->expects($this->any())
98 ->method(
'getCustomerGroupId')
100 $this->storeMock = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
101 ->disableOriginalConstructor()
103 $this->searchIndexNameResolver = $this
104 ->getMockBuilder(\
Magento\Elasticsearch\SearchAdapter\SearchIndexNameResolver::class)
105 ->disableOriginalConstructor()
107 $this->storeMock->expects($this->any())
108 ->method(
'getWebsiteId')
110 $this->storeMock->expects($this->any())
113 $this->clientConfig->expects($this->any())
114 ->method(
'getIndexName')
115 ->willReturn(
'indexName');
116 $this->clientConfig->expects($this->any())
117 ->method(
'getEntityType')
118 ->willReturn(
'product');
119 $this->clientMock = $this->getMockBuilder(\
Magento\Elasticsearch\Model\Client\Elasticsearch::class)
120 ->setMethods([
'query'])
121 ->disableOriginalConstructor()
123 $this->connectionManager->expects($this->any())
124 ->method(
'getConnection')
125 ->willReturn($this->clientMock);
127 $objectManagerHelper =
new ObjectManagerHelper($this);
128 $this->model = $objectManagerHelper->getObject(
129 \
Magento\Elasticsearch\SearchAdapter\Aggregation\Interval::class,
131 'connectionManager' => $this->connectionManager,
132 'fieldMapper' => $this->fieldMapper,
133 'clientConfig' => $this->clientConfig,
134 'searchIndexNameResolver' => $this->searchIndexNameResolver,
135 'fieldName' =>
'price_0_1',
137 'entityIds' => [265, 313, 281]
150 public function testLoad($limit, $offset, $lower, $upper)
152 $this->storeMock = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
153 ->disableOriginalConstructor()
155 $this->searchIndexNameResolver->expects($this->any())
156 ->method(
'getIndexName')
157 ->willReturn(
'magento2_product_1');
158 $this->clientConfig->expects($this->any())
159 ->method(
'getEntityType')
160 ->willReturn(
'document');
162 $expectedResult = [25];
164 $this->clientMock->expects($this->once())
181 $this->model->load($limit, $offset, $lower, $upper)
200 'price_0_1' => [
'25']
207 $this->storeMock = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
208 ->disableOriginalConstructor()
210 $this->searchIndexNameResolver->expects($this->any())
211 ->method(
'getIndexName')
212 ->willReturn(
'magento2_product_1');
213 $this->clientConfig->expects($this->any())
214 ->method(
'getEntityType')
215 ->willReturn(
'document');
217 $expectedResult = [
'25.0'];
219 $this->clientMock->expects($this->any())
221 ->willReturn($queryResult);
237 $queryResult = [
'hits' => [
'total'=>
'0']];
239 $this->storeMock = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
240 ->disableOriginalConstructor()
242 $this->searchIndexNameResolver->expects($this->any())
243 ->method(
'getIndexName')
244 ->willReturn(
'magento2_product_1');
245 $this->clientConfig->expects($this->any())
246 ->method(
'getEntityType')
247 ->willReturn(
'document');
249 $this->clientMock->expects($this->any())
251 ->willReturn($queryResult);
272 'price_0_1' => [
'25']
279 $this->storeMock = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
280 ->disableOriginalConstructor()
282 $this->searchIndexNameResolver->expects($this->any())
283 ->method(
'getIndexName')
284 ->willReturn(
'magento2_product_1');
285 $this->clientConfig->expects($this->any())
286 ->method(
'getEntityType')
287 ->willReturn(
'document');
289 $expectedResult = [
'25.0'];
291 $this->clientMock->expects($this->any())
293 ->willReturn($queryResult);
296 $this->model->loadNext(
$data, $rightIndex, $upper)
309 $queryResult = [
'hits' => [
'total'=>
'0']];
311 $this->storeMock = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
312 ->disableOriginalConstructor()
314 $this->searchIndexNameResolver->expects($this->any())
315 ->method(
'getIndexName')
316 ->willReturn(
'magento2_product_1');
317 $this->clientConfig->expects($this->any())
318 ->method(
'getEntityType')
319 ->willReturn(
'document');
321 $this->clientMock->expects($this->any())
323 ->willReturn($queryResult);
325 $this->model->loadNext(
$data, $rightIndex, $upper)
335 [
'6',
'2',
'24',
'42'],
static loadPrevParamsProvider()
testLoadPrevArray($data, $index, $lower)
testLoad($limit, $offset, $lower, $upper)
testLoadPrevFalse($data, $index, $lower)
static loadParamsProvider()
testLoadNextArray($data, $rightIndex, $upper)
testLoadNextFalse($data, $rightIndex, $upper)
static loadNextParamsProvider()