@@ -77,6 +77,7 @@ class ElasticsearchTest extends \PHPUnit\Framework\TestCase
77
77
* Setup
78
78
*
79
79
* @return void
80
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
80
81
*/
81
82
protected function setUp ()
82
83
{
@@ -93,55 +94,65 @@ protected function setUp()
93
94
->getMock ();
94
95
$ this ->clientConfig = $ this ->getMockBuilder (\Magento \Elasticsearch \Model \Config::class)
95
96
->disableOriginalConstructor ()
96
- ->setMethods ([
97
- 'getIndexPrefix ' ,
98
- 'getEntityType ' ,
99
- ])->getMock ();
97
+ ->setMethods (
98
+ [
99
+ 'getIndexPrefix ' ,
100
+ 'getEntityType ' ,
101
+ ]
102
+ )->getMock ();
100
103
$ this ->indexBuilder = $ this ->getMockBuilder (\Magento \Elasticsearch \Model \Adapter \Index \BuilderInterface::class)
101
104
->disableOriginalConstructor ()
102
105
->getMock ();
103
106
$ this ->logger = $ this ->getMockBuilder (\Psr \Log \LoggerInterface::class)
104
107
->disableOriginalConstructor ()
105
108
->getMock ();
106
109
$ elasticsearchClientMock = $ this ->getMockBuilder (\Elasticsearch \Client::class)
107
- ->setMethods ([
108
- 'indices ' ,
109
- 'ping ' ,
110
- 'bulk ' ,
111
- 'search ' ,
112
- ])
110
+ ->setMethods (
111
+ [
112
+ 'indices ' ,
113
+ 'ping ' ,
114
+ 'bulk ' ,
115
+ 'search ' ,
116
+ ]
117
+ )
113
118
->disableOriginalConstructor ()
114
119
->getMock ();
115
120
$ 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
- ])
121
+ ->setMethods (
122
+ [
123
+ 'exists ' ,
124
+ 'getSettings ' ,
125
+ 'create ' ,
126
+ 'putMapping ' ,
127
+ 'deleteMapping ' ,
128
+ 'existsAlias ' ,
129
+ 'updateAliases ' ,
130
+ 'stats '
131
+ ]
132
+ )
126
133
->disableOriginalConstructor ()
127
134
->getMock ();
128
135
$ elasticsearchClientMock ->expects ($ this ->any ())
129
136
->method ('indices ' )
130
137
->willReturn ($ indicesMock );
131
138
$ this ->client = $ this ->getMockBuilder (\Magento \Elasticsearch \Model \Client \Elasticsearch::class)
132
- ->setConstructorArgs ([
133
- 'options ' => $ this ->getClientOptions (),
134
- 'elasticsearchClient ' => $ elasticsearchClientMock
135
- ])
139
+ ->setConstructorArgs (
140
+ [
141
+ 'options ' => $ this ->getClientOptions (),
142
+ 'elasticsearchClient ' => $ elasticsearchClientMock
143
+ ]
144
+ )
136
145
->getMock ();
137
146
$ this ->connectionManager ->expects ($ this ->any ())
138
147
->method ('getConnection ' )
139
148
->willReturn ($ this ->client );
140
149
$ this ->fieldMapper ->expects ($ this ->any ())
141
150
->method ('getAllAttributesTypes ' )
142
- ->willReturn ([
143
- 'name ' => 'string ' ,
144
- ]);
151
+ ->willReturn (
152
+ [
153
+ 'name ' => 'string ' ,
154
+ ]
155
+ );
145
156
$ this ->clientConfig ->expects ($ this ->any ())
146
157
->method ('getIndexPrefix ' )
147
158
->willReturn ('indexName ' );
@@ -151,12 +162,14 @@ protected function setUp()
151
162
$ this ->indexNameResolver = $ this ->getMockBuilder (
152
163
\Magento \Elasticsearch \Model \Adapter \Index \IndexNameResolver::class
153
164
)
154
- ->setMethods ([
155
- 'getIndexName ' ,
156
- 'getIndexNamespace ' ,
157
- 'getIndexFromAlias ' ,
158
- 'getIndexNameForAlias ' ,
159
- ])
165
+ ->setMethods (
166
+ [
167
+ 'getIndexName ' ,
168
+ 'getIndexNamespace ' ,
169
+ 'getIndexFromAlias ' ,
170
+ 'getIndexNameForAlias ' ,
171
+ ]
172
+ )
160
173
->disableOriginalConstructor ()
161
174
->getMock ();
162
175
$ this ->batchDocumentDataMapper = $ this ->getMockBuilder (
@@ -216,9 +229,11 @@ public function testPrepareDocsPerStore()
216
229
{
217
230
$ this ->batchDocumentDataMapper ->expects ($ this ->once ())
218
231
->method ('map ' )
219
- ->willReturn ([
220
- 'name ' => 'Product Name ' ,
221
- ]);
232
+ ->willReturn (
233
+ [
234
+ 'name ' => 'Product Name ' ,
235
+ ]
236
+ );
222
237
$ this ->assertInternalType (
223
238
'array ' ,
224
239
$ this ->model ->prepareDocsPerStore (
@@ -352,9 +367,11 @@ public function testConnectException()
352
367
{
353
368
$ connectionManager = $ this ->getMockBuilder (\Magento \Elasticsearch \SearchAdapter \ConnectionManager::class)
354
369
->disableOriginalConstructor ()
355
- ->setMethods ([
356
- 'getConnection ' ,
357
- ])
370
+ ->setMethods (
371
+ [
372
+ 'getConnection ' ,
373
+ ]
374
+ )
358
375
->getMock ();
359
376
360
377
$ connectionManager ->expects ($ this ->any ())
0 commit comments