Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 1a33193

Browse files
author
Joan He
committed
MAGETWO-89567: Cannot set 'user' save handler by ini_set()
- fix integration test failure
1 parent c174c67 commit 1a33193

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ public function testConstructor(
317317
$expectedSavePath,
318318
$givenSaveHandler,
319319
$expectedSaveHandler
320-
)
321-
{
320+
) {
322321
global $mockPHPFunctions;
323322
$mockPHPFunctions = $mockPHPFunctionNum;
324323

dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use Magento\Framework\App\DeploymentConfig;
1414
use Magento\Framework\App\State;
15-
use Magento\Framework\Session\Config\ConfigInterface;
1615

1716
// @codingStandardsIgnoreEnd
1817

@@ -124,21 +123,6 @@ protected function setUp()
124123
ini_set('session.name', $this->sessionName);
125124

126125
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
127-
$deploymentConfigMock = $this->createMock(DeploymentConfig::class);
128-
$deploymentConfigMock->method('get')
129-
->willReturnCallback(function ($configPath) {
130-
switch ($configPath) {
131-
case Config::PARAM_SESSION_SAVE_METHOD:
132-
return 'db';
133-
case Config::PARAM_SESSION_CACHE_LIMITER:
134-
return 'private_no_expire';
135-
case Config::PARAM_SESSION_SAVE_PATH:
136-
return 'explicit_save_path';
137-
default:
138-
return null;
139-
}
140-
});
141-
$this->objectManager->addSharedInstance($deploymentConfigMock, DeploymentConfig::class);
142126

143127
/** @var \Magento\Framework\Session\SidResolverInterface $sidResolver */
144128
$this->appState = $this->getMockBuilder(State::class)
@@ -167,7 +151,6 @@ protected function tearDown()
167151
$this->model->destroy();
168152
$this->model = null;
169153
}
170-
$this->objectManager->removeSharedInstance(DeploymentConfig::class);
171154
}
172155

173156
public function testSessionNameFromIni()
@@ -321,13 +304,32 @@ public function testConstructor()
321304
{
322305
global $mockPHPFunctions;
323306
$mockPHPFunctions = true;
307+
308+
$deploymentConfigMock = $this->createMock(DeploymentConfig::class);
309+
$deploymentConfigMock->method('get')
310+
->willReturnCallback(function ($configPath) {
311+
switch ($configPath) {
312+
case Config::PARAM_SESSION_SAVE_METHOD:
313+
return 'db';
314+
case Config::PARAM_SESSION_CACHE_LIMITER:
315+
return 'private_no_expire';
316+
case Config::PARAM_SESSION_SAVE_PATH:
317+
return 'explicit_save_path';
318+
default:
319+
return null;
320+
}
321+
});
322+
$sessionConfig = $this->objectManager->create(Config::class, ['deploymentConfig' => $deploymentConfigMock]);
323+
$saveHandler = $this->objectManager->create(SaveHandler::class, ['sessionConfig' => $sessionConfig]);
324+
324325
$this->model = $this->objectManager->create(
325326
\Magento\Framework\Session\SessionManager::class,
326327
[
327-
'sidResolver' => $this->sidResolver
328+
'sidResolver' => $this->sidResolver,
329+
'saveHandler' => $saveHandler,
330+
'sessionConfig' => $sessionConfig,
328331
]
329332
);
330-
$sessionConfig = $this->objectManager->get(ConfigInterface::class);
331333
$this->assertEquals('db', $sessionConfig->getOption('session.save_handler'));
332334
$this->assertEquals('private_no_expire', $sessionConfig->getOption('session.cache_limiter'));
333335
$this->assertEquals('explicit_save_path', $sessionConfig->getOption('session.save_path'));

0 commit comments

Comments
 (0)