Skip to content

Commit 93af932

Browse files
MC-19450: Adapt integration tests to elasticsearch
1 parent 8fad1eb commit 93af932

File tree

1 file changed

+55
-39
lines changed

1 file changed

+55
-39
lines changed

app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/ElasticsearchTest.php

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -93,55 +93,65 @@ protected function setUp()
9393
->getMock();
9494
$this->clientConfig = $this->getMockBuilder(\Magento\Elasticsearch\Model\Config::class)
9595
->disableOriginalConstructor()
96-
->setMethods([
97-
'getIndexPrefix',
98-
'getEntityType',
99-
])->getMock();
96+
->setMethods(
97+
[
98+
'getIndexPrefix',
99+
'getEntityType',
100+
]
101+
)->getMock();
100102
$this->indexBuilder = $this->getMockBuilder(\Magento\Elasticsearch\Model\Adapter\Index\BuilderInterface::class)
101103
->disableOriginalConstructor()
102104
->getMock();
103105
$this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
104106
->disableOriginalConstructor()
105107
->getMock();
106108
$elasticsearchClientMock = $this->getMockBuilder(\Elasticsearch\Client::class)
107-
->setMethods([
108-
'indices',
109-
'ping',
110-
'bulk',
111-
'search',
112-
])
109+
->setMethods(
110+
[
111+
'indices',
112+
'ping',
113+
'bulk',
114+
'search',
115+
]
116+
)
113117
->disableOriginalConstructor()
114118
->getMock();
115119
$indicesMock = $this->getMockBuilder(\Elasticsearch\Namespaces\IndicesNamespace::class)
116-
->setMethods([
117-
'exists',
118-
'getSettings',
119-
'create',
120-
'putMapping',
121-
'deleteMapping',
122-
'existsAlias',
123-
'updateAliases',
124-
'stats'
125-
])
120+
->setMethods(
121+
[
122+
'exists',
123+
'getSettings',
124+
'create',
125+
'putMapping',
126+
'deleteMapping',
127+
'existsAlias',
128+
'updateAliases',
129+
'stats'
130+
]
131+
)
126132
->disableOriginalConstructor()
127133
->getMock();
128134
$elasticsearchClientMock->expects($this->any())
129135
->method('indices')
130136
->willReturn($indicesMock);
131137
$this->client = $this->getMockBuilder(\Magento\Elasticsearch\Model\Client\Elasticsearch::class)
132-
->setConstructorArgs([
133-
'options' => $this->getClientOptions(),
134-
'elasticsearchClient' => $elasticsearchClientMock
135-
])
138+
->setConstructorArgs(
139+
[
140+
'options' => $this->getClientOptions(),
141+
'elasticsearchClient' => $elasticsearchClientMock
142+
]
143+
)
136144
->getMock();
137145
$this->connectionManager->expects($this->any())
138146
->method('getConnection')
139147
->willReturn($this->client);
140148
$this->fieldMapper->expects($this->any())
141149
->method('getAllAttributesTypes')
142-
->willReturn([
143-
'name' => 'string',
144-
]);
150+
->willReturn(
151+
[
152+
'name' => 'string',
153+
]
154+
);
145155
$this->clientConfig->expects($this->any())
146156
->method('getIndexPrefix')
147157
->willReturn('indexName');
@@ -151,12 +161,14 @@ protected function setUp()
151161
$this->indexNameResolver = $this->getMockBuilder(
152162
\Magento\Elasticsearch\Model\Adapter\Index\IndexNameResolver::class
153163
)
154-
->setMethods([
155-
'getIndexName',
156-
'getIndexNamespace',
157-
'getIndexFromAlias',
158-
'getIndexNameForAlias',
159-
])
164+
->setMethods(
165+
[
166+
'getIndexName',
167+
'getIndexNamespace',
168+
'getIndexFromAlias',
169+
'getIndexNameForAlias',
170+
]
171+
)
160172
->disableOriginalConstructor()
161173
->getMock();
162174
$this->batchDocumentDataMapper = $this->getMockBuilder(
@@ -216,9 +228,11 @@ public function testPrepareDocsPerStore()
216228
{
217229
$this->batchDocumentDataMapper->expects($this->once())
218230
->method('map')
219-
->willReturn([
220-
'name' => 'Product Name',
221-
]);
231+
->willReturn(
232+
[
233+
'name' => 'Product Name',
234+
]
235+
);
222236
$this->assertInternalType(
223237
'array',
224238
$this->model->prepareDocsPerStore(
@@ -352,9 +366,11 @@ public function testConnectException()
352366
{
353367
$connectionManager = $this->getMockBuilder(\Magento\Elasticsearch\SearchAdapter\ConnectionManager::class)
354368
->disableOriginalConstructor()
355-
->setMethods([
356-
'getConnection',
357-
])
369+
->setMethods(
370+
[
371+
'getConnection',
372+
]
373+
)
358374
->getMock();
359375

360376
$connectionManager->expects($this->any())

0 commit comments

Comments
 (0)