@@ -115,6 +115,9 @@ class SessionManagerTest extends \PHPUnit\Framework\TestCase
115
115
*/
116
116
private $ appState ;
117
117
118
+ /**
119
+ * @inheritdoc
120
+ */
118
121
protected function setUp (): void
119
122
{
120
123
$ this ->sessionName = 'frontEndSession ' ;
@@ -250,8 +253,6 @@ public function testIsValidForHost()
250
253
$ this ->model ->destroy ();
251
254
}
252
255
253
- /**
254
- */
255
256
public function testStartAreaNotSet ()
256
257
{
257
258
$ this ->expectException (\Magento \Framework \Exception \SessionException::class);
@@ -283,17 +284,23 @@ public function testStartAreaNotSet()
283
284
$ this ->model ->start ();
284
285
}
285
286
286
- public function testConstructor ()
287
+ /**
288
+ * @param string $saveMethod
289
+ * @dataProvider dataConstructor
290
+ *
291
+ * @return void
292
+ */
293
+ public function testConstructor (string $ saveMethod ): void
287
294
{
288
295
global $ mockPHPFunctions ;
289
296
$ mockPHPFunctions = true ;
290
297
291
298
$ deploymentConfigMock = $ this ->createMock (DeploymentConfig::class);
292
299
$ deploymentConfigMock ->method ('get ' )
293
- ->willReturnCallback (function ($ configPath ) {
300
+ ->willReturnCallback (function ($ configPath ) use ( $ saveMethod ) {
294
301
switch ($ configPath ) {
295
302
case Config::PARAM_SESSION_SAVE_METHOD :
296
- return ' db ' ;
303
+ return $ saveMethod ;
297
304
case Config::PARAM_SESSION_CACHE_LIMITER :
298
305
return 'private_no_expire ' ;
299
306
case Config::PARAM_SESSION_SAVE_PATH :
@@ -313,13 +320,13 @@ public function testConstructor()
313
320
'sessionConfig ' => $ sessionConfig ,
314
321
]
315
322
);
316
- $ this ->assertEquals (' db ' , $ sessionConfig ->getOption ('session.save_handler ' ));
323
+ $ this ->assertEquals ($ saveMethod , $ sessionConfig ->getOption ('session.save_handler ' ));
317
324
$ this ->assertEquals ('private_no_expire ' , $ sessionConfig ->getOption ('session.cache_limiter ' ));
318
325
$ this ->assertEquals ('explicit_save_path ' , $ sessionConfig ->getOption ('session.save_path ' ));
319
326
$ this ->assertArrayHasKey ('session.use_only_cookies ' , self ::$ isIniSetInvoked );
320
327
$ this ->assertEquals ('1 ' , self ::$ isIniSetInvoked ['session.use_only_cookies ' ]);
321
328
foreach ($ sessionConfig ->getOptions () as $ option => $ value ) {
322
- if ($ option== 'session.save_handler ' ) {
329
+ if ($ option === 'session.save_handler ' && $ value !== ' memcached ' ) {
323
330
$ this ->assertArrayNotHasKey ('session.save_handler ' , self ::$ isIniSetInvoked );
324
331
} else {
325
332
$ this ->assertArrayHasKey ($ option , self ::$ isIniSetInvoked );
@@ -329,6 +336,19 @@ public function testConstructor()
329
336
$ this ->assertTrue (self ::$ isSessionSetSaveHandlerInvoked );
330
337
}
331
338
339
+ /**
340
+ * @return array
341
+ */
342
+ public function dataConstructor (): array
343
+ {
344
+ return [
345
+ [Config::PARAM_SESSION_SAVE_METHOD =>'db ' ],
346
+ [Config::PARAM_SESSION_SAVE_METHOD =>'redis ' ],
347
+ [Config::PARAM_SESSION_SAVE_METHOD =>'memcached ' ],
348
+ [Config::PARAM_SESSION_SAVE_METHOD =>'user ' ],
349
+ ];
350
+ }
351
+
332
352
private function initializeModel (): void
333
353
{
334
354
$ this ->model = $ this ->objectManager ->create (
0 commit comments