@@ -107,9 +107,13 @@ protected function setUp()
107
107
108
108
/**
109
109
* @param array $config
110
+ * @param bool $isGreaterOrEqual
111
+ * @param string $address
112
+ * @param int $port
113
+ * @throws StepException
110
114
* @dataProvider executeDataProvider
111
115
*/
112
- public function testExecute (array $ config , bool $ isGreaterOrEqual )
116
+ public function testExecute (array $ config , bool $ isGreaterOrEqual, $ address , $ port )
113
117
{
114
118
$ this ->magentoVersion ->expects ($ this ->any ())
115
119
->method ('isGreaterOrEqual ' )
@@ -128,10 +132,15 @@ public function testExecute(array $config, bool $isGreaterOrEqual)
128
132
->method ('info ' )
129
133
->with ('Updating cache configuration. ' );
130
134
131
- $ this ->socketCreateMock ->expects ($ this ->once ());
135
+ $ sock = socket_create (AF_INET , SOCK_STREAM , SOL_TCP );
136
+ $ this ->socketCreateMock ->expects ($ this ->once ())
137
+ ->willReturn ($ sock );
132
138
$ this ->socketConnectMock ->expects ($ this ->once ())
139
+ ->with ($ sock , $ address , $ port )
133
140
->willReturn (true );
134
- $ this ->socketCloseMock ->expects ($ this ->once ());
141
+ $ this ->socketCloseMock ->expects ($ this ->once ())
142
+ ->with ($ sock );
143
+ socket_close ($ sock );
135
144
136
145
$ this ->step ->execute ();
137
146
}
@@ -152,6 +161,8 @@ public function executeDataProvider(): array
152
161
],
153
162
],
154
163
'isGreaterOrEqual ' => false ,
164
+ 'address ' => 'localhost ' ,
165
+ 'port ' => 6370
155
166
],
156
167
'backend model with remote_backend_options ' => [
157
168
'config ' => [
@@ -168,6 +179,42 @@ public function executeDataProvider(): array
168
179
],
169
180
],
170
181
'isGreaterOrEqual ' => true ,
182
+ 'address ' => 'localhost ' ,
183
+ 'port ' => 6370
184
+ ],
185
+ 'Server contains port data ' => [
186
+ 'config ' => [
187
+ 'frontend ' => [
188
+ 'frontName ' => [
189
+ 'backend ' => CacheFactory::REDIS_BACKEND_REMOTE_SYNCHRONIZED_CACHE ,
190
+ 'backend_options ' => [
191
+ 'remote_backend_options ' => [
192
+ 'server ' => '127.0.0.1:6371 ' ,
193
+ ],
194
+ ],
195
+ ],
196
+ ],
197
+ ],
198
+ 'isGreaterOrEqual ' => true ,
199
+ 'address ' => '127.0.0.1 ' ,
200
+ 'port ' => 6371
201
+ ],
202
+ 'Server contains protocol and port data ' => [
203
+ 'config ' => [
204
+ 'frontend ' => [
205
+ 'frontName ' => [
206
+ 'backend ' => CacheFactory::REDIS_BACKEND_REMOTE_SYNCHRONIZED_CACHE ,
207
+ 'backend_options ' => [
208
+ 'remote_backend_options ' => [
209
+ 'server ' => 'tcp://localhost:6379 ' ,
210
+ ],
211
+ ],
212
+ ],
213
+ ],
214
+ ],
215
+ 'isGreaterOrEqual ' => true ,
216
+ 'address ' => 'localhost ' ,
217
+ 'port ' => 6379
171
218
],
172
219
];
173
220
}
@@ -300,13 +347,17 @@ public function testExecuteMixedBackends()
300
347
}
301
348
302
349
/**
350
+ * @param $options
351
+ * @param $errorMessage
303
352
* @throws StepException
353
+ *
354
+ * @dataProvider dataProviderExecuteWithWrongConfiguration
304
355
*/
305
- public function testExecuteWithWrongConfiguration ()
356
+ public function testExecuteWithWrongConfiguration ($ options , $ errorMessage )
306
357
{
307
358
$ this ->expectExceptionCode (Error::DEPLOY_WRONG_CACHE_CONFIGURATION );
308
359
$ this ->expectException (StepException::class);
309
- $ this ->expectExceptionMessage (' Missing required Redis configuration! ' );
360
+ $ this ->expectExceptionMessage ($ errorMessage );
310
361
311
362
$ this ->configReaderMock ->expects ($ this ->once ())
312
363
->method ('read ' )
@@ -316,13 +367,31 @@ public function testExecuteWithWrongConfiguration()
316
367
->willReturn ([
317
368
'frontend ' => ['frontName ' => [
318
369
'backend ' => 'Cm_Cache_Backend_Redis ' ,
319
- 'backend_options ' => [ ' server ' => ' redis.server ' ] ,
370
+ 'backend_options ' => $ options ,
320
371
]],
321
372
]);
322
373
323
374
$ this ->step ->execute ();
324
375
}
325
376
377
+ public function dataProviderExecuteWithWrongConfiguration ()
378
+ {
379
+ return [
380
+ [
381
+ ['server ' => 'redis.server ' ],
382
+ 'Missing required Redis configuration \'port \'! '
383
+ ],
384
+ [
385
+ ['server ' => '' , 'port ' => '6379 ' ],
386
+ 'Missing required Redis configuration \'server \'! '
387
+ ],
388
+ [
389
+ ['port ' => '6379 ' ],
390
+ 'Missing required Redis configuration \'server \'! '
391
+ ],
392
+ ];
393
+ }
394
+
326
395
/**
327
396
* @throws StepException
328
397
*/
0 commit comments