9 use Psr\Log\LoggerInterface;
66 $this->objectManager =
new ObjectManagerHelper($this);
68 $this->connectionManager = $this->getMockBuilder(\
Magento\Elasticsearch\SearchAdapter\ConnectionManager::class)
69 ->disableOriginalConstructor()
75 $this->clientConfig = $this->getMockBuilder(\
Magento\Elasticsearch\Model\Config::class)
76 ->disableOriginalConstructor()
84 $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
85 ->disableOriginalConstructor()
88 $elasticsearchClientMock = $this->getMockBuilder(\Elasticsearch\Client::class)
96 ->disableOriginalConstructor()
99 $indicesMock = $this->getMockBuilder(\Elasticsearch\Namespaces\IndicesNamespace::class)
110 ->disableOriginalConstructor()
112 $elasticsearchClientMock->expects($this->any())
114 ->willReturn($indicesMock);
115 $this->client = $this->getMockBuilder(\
Magento\Elasticsearch\Model\Client\Elasticsearch::class)
116 ->setConstructorArgs([
118 'elasticsearchClient' => $elasticsearchClientMock
122 $this->connectionManager->expects($this->any())
123 ->method(
'getConnection')
124 ->willReturn($this->client);
126 $this->clientConfig->expects($this->any())
127 ->method(
'getIndexPrefix')
128 ->willReturn(
'indexName');
129 $this->clientConfig->expects($this->any())
130 ->method(
'getEntityType')
131 ->willReturn(
'product');
132 $this->entityType =
'product';
137 \
Magento\Elasticsearch\Model\Adapter\Index\IndexNameResolver::class,
139 'connectionManager' => $this->connectionManager,
140 'clientConfig' => $this->clientConfig,
141 'logger' => $this->logger,
152 $this->clientConfig->expects($this->any())
153 ->method(
'getIndexPrefix')
154 ->willReturn(
'indexName');
157 'indexName_product_1',
158 $this->model->getIndexNameForAlias($this->storeId, $this->entityType)
167 $preparedIndex = [
'1' =>
'product'];
171 $this->model->getIndexName($this->storeId, $this->entityType, $preparedIndex)
183 'indexName_product_1_v1',
184 $this->model->getIndexName($this->storeId, $this->entityType, $preparedIndex)
194 'indexName_product_1_v',
195 $this->model->getIndexPattern($this->storeId, $this->entityType)
204 $this->client->expects($this->any())
206 ->with(
'indexName_product_1')
209 'indexName_product_1_v2' => [
211 'indexName_product_1' => [],
217 $this->client->expects($this->any())
218 ->method(
'existsAlias')
219 ->with(
'indexName_product_1')
223 'indexName_product_1_v2',
224 $this->model->getIndexFromAlias($this->storeId, $this->entityType)
234 ->disableOriginalConstructor()
241 ->method(
'getConnection')
242 ->willThrowException(
new \Exception(
'Something went wrong'));
244 $this->objectManager->getObject(
245 \
Magento\Elasticsearch\Model\Adapter\Index\IndexNameResolver::class,
248 'clientConfig' => $this->clientConfig,
249 'logger' => $this->logger,
262 $this->model->getIndexMapping(
'catalogsearch_fulltext')
273 $this->model->getIndexMapping(
'else_index_id')
285 'hostname' =>
'localhost',
288 'index' =>
'magento2',
290 'username' =>
'user',
291 'password' =>
'my-password',
testUpdateAliasWithOldIndex()
testGetIndexNameCatalogSearchFullText()
testGetIndexNameWithPreparedIndex()
testGetIndexNameForAlias()
testGetIndexNameWithoutPreparedIndexWithIndexName()