15
15
use Magento \MagentoCloud \Config \Validator \ResultFactory ;
16
16
use Magento \MagentoCloud \Package \MagentoVersion ;
17
17
use Magento \MagentoCloud \Package \Manager ;
18
+ use Magento \MagentoCloud \Package \UndefinedPackageException ;
18
19
use Magento \MagentoCloud \Service \ElasticSearch ;
19
20
use PHPUnit \Framework \MockObject \MockObject ;
20
21
use PHPUnit \Framework \TestCase ;
@@ -63,7 +64,7 @@ class ElasticSearchVersionTest extends TestCase
63
64
/**
64
65
* @inheritdoc
65
66
*/
66
- public function setUp ()
67
+ public function setUp (): void
67
68
{
68
69
$ this ->resultFactoryMock = $ this ->createMock (ResultFactory::class);
69
70
$ this ->managerMock = $ this ->createMock (Manager::class);
@@ -82,7 +83,7 @@ public function setUp()
82
83
);
83
84
}
84
85
85
- public function testValidateElasticSearchServiceNotExists ()
86
+ public function testValidateElasticSearchServiceNotExists (): void
86
87
{
87
88
$ this ->elasticSearchMock ->expects ($ this ->once ())
88
89
->method ('getVersion ' )
@@ -99,7 +100,7 @@ public function testValidateElasticSearchServiceNotExists()
99
100
$ this ->assertInstanceOf (Success::class, $ this ->validator ->validate ());
100
101
}
101
102
102
- public function testValidatePackageNotExists ()
103
+ public function testValidatePackageNotExists (): void
103
104
{
104
105
$ this ->searchEngineMock ->expects ($ this ->once ())
105
106
->method ('isESFamily ' )
@@ -110,7 +111,7 @@ public function testValidatePackageNotExists()
110
111
$ this ->managerMock ->expects ($ this ->once ())
111
112
->method ('get ' )
112
113
->with ('elasticsearch/elasticsearch ' )
113
- ->willThrowException (new \ Exception ('package doesn \'t exist ' ));
114
+ ->willThrowException (new UndefinedPackageException ('package doesn \'t exist ' ));
114
115
$ this ->loggerMock ->expects ($ this ->once ())
115
116
->method ('warning ' )
116
117
->with ('Can \'t validate version of elasticsearch: package doesn \'t exist ' );
@@ -120,7 +121,7 @@ public function testValidatePackageNotExists()
120
121
$ this ->assertInstanceOf (Success::class, $ this ->validator ->validate ());
121
122
}
122
123
123
- public function testValidateElasticSearchServiceExistsAndNotConfigured ()
124
+ public function testValidateElasticSearchServiceExistsAndNotConfigured (): void
124
125
{
125
126
$ this ->searchEngineMock ->expects ($ this ->once ())
126
127
->method ('isESFamily ' )
@@ -154,7 +155,7 @@ public function testValidate(
154
155
string $ magentoVersion = '2.2 ' ,
155
156
string $ errorMessage = '' ,
156
157
string $ errorSuggestion = ''
157
- ) {
158
+ ): void {
158
159
$ this ->magentoVersionMock ->expects ($ this ->any ())
159
160
->method ('getVersion ' )
160
161
->willReturn ($ magentoVersion );
@@ -186,6 +187,8 @@ public function testValidate(
186
187
187
188
/**
188
189
* @return array
190
+ *
191
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
189
192
*/
190
193
public function validateDataProvider (): array
191
194
{
@@ -202,6 +205,8 @@ public function validateDataProvider(): array
202
205
['1.7 ' , '2.9 ' , Success::class],
203
206
['5.1 ' , '5.0 ' , Success::class],
204
207
['5.2 ' , '5.1 ' , Success::class],
208
+ ['7.0 ' , '7.1 ' , Success::class],
209
+ ['7.4 ' , '7.2 ' , Success::class],
205
210
['6.1 ' , '2.0 ' , Error::class],
206
211
[
207
212
'6.2 ' ,
@@ -210,7 +215,7 @@ public function validateDataProvider(): array
210
215
'2.3.0 ' ,
211
216
'Elasticsearch service version 6.2 on infrastructure layer is not compatible with current version of ' .
212
217
'elasticsearch/elasticsearch module (5.0), used by your Magento application. ' ,
213
- 'You can fix this issue by upgrading the Elasticsearch service on your ' .
218
+ 'You can fix this issue by downgrading the Elasticsearch service on your ' .
214
219
'Magento Cloud infrastructure to version 5.x. '
215
220
],
216
221
[
@@ -231,7 +236,7 @@ public function validateDataProvider(): array
231
236
'2.1.4 ' ,
232
237
'Elasticsearch service version 5.0 on infrastructure layer is not compatible with current version of ' .
233
238
'elasticsearch/elasticsearch module (2.0), used by your Magento application. ' ,
234
- 'You can fix this issue by upgrading the Elasticsearch service on your ' .
239
+ 'You can fix this issue by downgrading the Elasticsearch service on your ' .
235
240
'Magento Cloud infrastructure to version 1.x or 2.x. '
236
241
],
237
242
[
@@ -280,6 +285,16 @@ public function validateDataProvider(): array
280
285
'You can fix this issue by upgrading the Elasticsearch service on your ' .
281
286
'Magento Cloud infrastructure to version 5.x. '
282
287
],
288
+ [
289
+ '7.4 ' ,
290
+ '6.2 ' ,
291
+ Error::class,
292
+ '2.4.0 ' ,
293
+ 'Elasticsearch service version 7.4 on infrastructure layer is not compatible with current version of ' .
294
+ 'elasticsearch/elasticsearch module (6.2), used by your Magento application. ' ,
295
+ 'You can fix this issue by downgrading the Elasticsearch service on your ' .
296
+ 'Magento Cloud infrastructure to version 6.x. '
297
+ ],
283
298
];
284
299
}
285
300
}
0 commit comments