diff --git a/composer.json b/composer.json index 73115b15a9f32a8af1a49a14a7658cd5daf9804c..e9880765b172e765285b516db117e85a829b562b 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,25 @@ "OSL-3.0", "AFL-3.0" ], + "repositories": [ + { + "type": "package", + "package": { + "name": "colinmollenhour/php-redis-session-abstract", + "version": "1.0.100", + "source": { + "url": "https://github.com/colinmollenhour/php-redis-session-abstract.git", + "type": "git", + "reference": "95330b7f29663dab81f53d1a438e4d927b6c5f66" + }, + "autoload": { + "psr-0": { + "Cm\\RedisSession\\": "src/" + } + } + } + } + ], "require": { "php": "~5.5.22|~5.6.0|~7.0.0", "zendframework/zend-stdlib": "~2.4.6", @@ -33,7 +52,7 @@ "zendframework/zend-http": "~2.4.6", "magento/zendframework1": "1.12.16", "colinmollenhour/credis": "1.6", - "colinmollenhour/php-redis-session-abstract": "1.0", + "colinmollenhour/php-redis-session-abstract": "1.0.100", "composer/composer": "1.0.0-beta1", "monolog/monolog": "1.16.0", "oyejorge/less.php": "1.7.0.3", diff --git a/composer.lock b/composer.lock index 4aaae63b403d43bf5ce7a75886dc6c8cedb6adb0..ab35246723931cd1c3add2bc0197f89c12676e2f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "d81a16c234a62403d9b5b06057393d9d", - "content-hash": "cd415001aebab7eb87bb62e2223509fc", + "hash": "5a52eec976eea4fade155b472365d805", + "content-hash": "2116af7fe8db4568fecdd0d554db22c3", "packages": [ { "name": "braintree/braintree_php", @@ -95,41 +95,18 @@ }, { "name": "colinmollenhour/php-redis-session-abstract", - "version": "v1.0", + "version": "1.0.100", "source": { "type": "git", "url": "https://github.com/colinmollenhour/php-redis-session-abstract.git", - "reference": "1308ddc08e2adbe303f7f8b8ead9beb5f2f2adf9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/colinmollenhour/php-redis-session-abstract/zipball/1308ddc08e2adbe303f7f8b8ead9beb5f2f2adf9", - "reference": "1308ddc08e2adbe303f7f8b8ead9beb5f2f2adf9", - "shasum": "" - }, - "require": { - "colinmollenhour/credis": "1.6", - "magento/zendframework1": "1.12.16", - "php": "~5.5.0|~5.6.0|~7.0.0" + "reference": "95330b7f29663dab81f53d1a438e4d927b6c5f66" }, "type": "library", "autoload": { "psr-0": { "Cm\\RedisSession\\": "src/" } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Colin Mollenhour" - } - ], - "description": "A Redis-based session handler with optimistic locking", - "homepage": "https://github.com/colinmollenhour/php-redis-session-abstract", - "time": "2016-01-14 16:04:27" + } }, { "name": "composer/composer", @@ -208,16 +185,16 @@ }, { "name": "composer/semver", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "df4463baa9f44fe6cf0a6da4fde2934d4c0a2747" + "reference": "84c47f3d8901440403217afc120683c7385aecb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/df4463baa9f44fe6cf0a6da4fde2934d4c0a2747", - "reference": "df4463baa9f44fe6cf0a6da4fde2934d4c0a2747", + "url": "https://api.github.com/repos/composer/semver/zipball/84c47f3d8901440403217afc120683c7385aecb8", + "reference": "84c47f3d8901440403217afc120683c7385aecb8", "shasum": "" }, "require": { @@ -266,28 +243,28 @@ "validation", "versioning" ], - "time": "2016-02-25 22:23:39" + "time": "2016-03-30 13:16:03" }, { "name": "composer/spdx-licenses", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/composer/spdx-licenses.git", - "reference": "9e1c3926bb0842812967213d7c92827bc5883671" + "reference": "547659c3cacd3ccfe1b4714c2ff88cafc6b6793b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/9e1c3926bb0842812967213d7c92827bc5883671", - "reference": "9e1c3926bb0842812967213d7c92827bc5883671", + "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/547659c3cacd3ccfe1b4714c2ff88cafc6b6793b", + "reference": "547659c3cacd3ccfe1b4714c2ff88cafc6b6793b", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "^5.3.2 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.5", - "phpunit/phpunit-mock-objects": "~2.3" + "phpunit/phpunit": "^4.5 || ^5.0.5", + "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" }, "type": "library", "extra": { @@ -327,7 +304,7 @@ "spdx", "validator" ], - "time": "2015-10-05 11:27:42" + "time": "2016-03-25 10:57:10" }, { "name": "justinrainbow/json-schema", @@ -1181,16 +1158,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.8.3", + "version": "v2.8.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "78c468665c9568c3faaa9c416a7134308f2d85c3" + "reference": "47d2d8cade9b1c3987573d2943bb9352536cdb87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/78c468665c9568c3faaa9c416a7134308f2d85c3", - "reference": "78c468665c9568c3faaa9c416a7134308f2d85c3", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/47d2d8cade9b1c3987573d2943bb9352536cdb87", + "reference": "47d2d8cade9b1c3987573d2943bb9352536cdb87", "shasum": "" }, "require": { @@ -1237,20 +1214,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:19" + "time": "2016-03-07 14:04:32" }, { "name": "symfony/filesystem", - "version": "v2.8.3", + "version": "v2.8.4", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "65cb36b6539b1d446527d60457248f30d045464d" + "reference": "f08ffdf229252cd2745558cb2112df43903bcae4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/65cb36b6539b1d446527d60457248f30d045464d", - "reference": "65cb36b6539b1d446527d60457248f30d045464d", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/f08ffdf229252cd2745558cb2112df43903bcae4", + "reference": "f08ffdf229252cd2745558cb2112df43903bcae4", "shasum": "" }, "require": { @@ -1286,20 +1263,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-02-22 15:02:30" + "time": "2016-03-27 10:20:16" }, { "name": "symfony/finder", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723" + "reference": "c54e407b35bc098916704e9fd090da21da4c4f52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723", - "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723", + "url": "https://api.github.com/repos/symfony/finder/zipball/c54e407b35bc098916704e9fd090da21da4c4f52", + "reference": "c54e407b35bc098916704e9fd090da21da4c4f52", "shasum": "" }, "require": { @@ -1335,20 +1312,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-03-10 11:13:05" }, { "name": "symfony/process", - "version": "v2.8.3", + "version": "v2.8.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "7dedd5b60550f33dca16dd7e94ef8aca8b67bbfe" + "reference": "fb467471952ef5cf8497c029980e556b47545333" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/7dedd5b60550f33dca16dd7e94ef8aca8b67bbfe", - "reference": "7dedd5b60550f33dca16dd7e94ef8aca8b67bbfe", + "url": "https://api.github.com/repos/symfony/process/zipball/fb467471952ef5cf8497c029980e556b47545333", + "reference": "fb467471952ef5cf8497c029980e556b47545333", "shasum": "" }, "require": { @@ -1384,7 +1361,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-02-02 13:33:15" + "time": "2016-03-23 13:11:46" }, { "name": "tedivm/jshrink", @@ -4112,16 +4089,16 @@ }, { "name": "symfony/config", - "version": "v2.8.3", + "version": "v2.8.4", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "0f8f94e6a32b5c480024eed5fa5cbd2790d0ad19" + "reference": "5273f4724dc5288fe7a33cb08077ab9852621f2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/0f8f94e6a32b5c480024eed5fa5cbd2790d0ad19", - "reference": "0f8f94e6a32b5c480024eed5fa5cbd2790d0ad19", + "url": "https://api.github.com/repos/symfony/config/zipball/5273f4724dc5288fe7a33cb08077ab9852621f2c", + "reference": "5273f4724dc5288fe7a33cb08077ab9852621f2c", "shasum": "" }, "require": { @@ -4161,20 +4138,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-02-22 16:12:45" + "time": "2016-03-04 07:54:35" }, { "name": "symfony/dependency-injection", - "version": "v2.8.3", + "version": "v2.8.4", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "62251761a7615435b22ccf562384c588b431be44" + "reference": "f7b4a498e679fa440b16facb934680a1527ed48c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/62251761a7615435b22ccf562384c588b431be44", - "reference": "62251761a7615435b22ccf562384c588b431be44", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f7b4a498e679fa440b16facb934680a1527ed48c", + "reference": "f7b4a498e679fa440b16facb934680a1527ed48c", "shasum": "" }, "require": { @@ -4223,20 +4200,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-02-28 16:34:46" + "time": "2016-03-21 07:27:21" }, { "name": "symfony/stopwatch", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "4a204804952ff267ace88cf499e0b4bb302a475e" + "reference": "6015187088421e9499d8f8316bdb396f8b806c06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4a204804952ff267ace88cf499e0b4bb302a475e", - "reference": "4a204804952ff267ace88cf499e0b4bb302a475e", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6015187088421e9499d8f8316bdb396f8b806c06", + "reference": "6015187088421e9499d8f8316bdb396f8b806c06", "shasum": "" }, "require": { @@ -4272,20 +4249,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2016-01-03 15:35:16" + "time": "2016-03-04 07:55:57" }, { "name": "symfony/yaml", - "version": "v2.8.3", + "version": "v2.8.4", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995" + "reference": "584e52cb8f788a887553ba82db6caacb1d6260bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/2a4ee40acb880c56f29fb1b8886e7ffe94f3b995", - "reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995", + "url": "https://api.github.com/repos/symfony/yaml/zipball/584e52cb8f788a887553ba82db6caacb1d6260bb", + "reference": "584e52cb8f788a887553ba82db6caacb1d6260bb", "shasum": "" }, "require": { @@ -4321,7 +4298,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-02-23 07:41:20" + "time": "2016-03-04 07:54:35" }, { "name": "theseer/fdomdocument", diff --git a/lib/internal/Magento/Framework/Session/SaveHandler/Redis/Config.php b/lib/internal/Magento/Framework/Session/SaveHandler/Redis/Config.php index d4dce686583b060b6e98a8335bf96d9c04608598..1a23e2974f568d90c33d49067cc228f8666d6705 100644 --- a/lib/internal/Magento/Framework/Session/SaveHandler/Redis/Config.php +++ b/lib/internal/Magento/Framework/Session/SaveHandler/Redis/Config.php @@ -5,9 +5,14 @@ */ namespace Magento\Framework\Session\SaveHandler\Redis; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Store\Model\ScopeInterface as StoreScopeInterface; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\State; +/** + * Redis session save handler + */ class Config implements \Cm\RedisSession\Handler\ConfigInterface { /** @@ -95,6 +100,21 @@ class Config implements \Cm\RedisSession\Handler\ConfigInterface */ const PARAM_BREAK_AFTER = 'session/redis/break_after'; + /** + * Cookie lifetime config path + */ + const XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime'; + + /** + * Admin session lifetime config path + */ + const XML_PATH_ADMIN_SESSION_LIFETIME = 'admin/security/session_lifetime'; + + /** + * Session max lifetime + */ + const SESSION_MAX_LIFETIME = 31536000; + /** * Deployment config * @@ -102,14 +122,24 @@ class Config implements \Cm\RedisSession\Handler\ConfigInterface */ private $deploymentConfig; + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + /** * @param DeploymentConfig $deploymentConfig * @param State $appState + * @param ScopeConfigInterface $scopeConfig */ - public function __construct(DeploymentConfig $deploymentConfig, State $appState) - { + public function __construct( + DeploymentConfig $deploymentConfig, + State $appState, + ScopeConfigInterface $scopeConfig + ) { $this->deploymentConfig = $deploymentConfig; $this->appState = $appState; + $this->scopeConfig = $scopeConfig; } /** @@ -197,7 +227,7 @@ class Config implements \Cm\RedisSession\Handler\ConfigInterface */ public function getMaxLifetime() { - return $this->deploymentConfig->get(self::PARAM_MAX_LIFETIME); + return self::SESSION_MAX_LIFETIME; } /** @@ -247,4 +277,15 @@ class Config implements \Cm\RedisSession\Handler\ConfigInterface { return $this->deploymentConfig->get(self::PARAM_BREAK_AFTER . '_' . $this->appState->getAreaCode()); } + + /** + * {@inheritdoc} + */ + public function getLifetime() + { + if ($this->appState->getAreaCode() == \Magento\Framework\App\Area::AREA_ADMINHTML) { + return (int)$this->scopeConfig->getValue(self::XML_PATH_ADMIN_SESSION_LIFETIME); + } + return (int)$this->scopeConfig->getValue(self::XML_PATH_COOKIE_LIFETIME, StoreScopeInterface::SCOPE_STORE); + } } diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/ConfigTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/ConfigTest.php index f34ef8b756d3343620ce736529a089032ca0a403..c66c31d2fcdff67dcf11b21f35cb3a26c45950db 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/ConfigTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/ConfigTest.php @@ -5,35 +5,44 @@ */ namespace Magento\Framework\Session\Test\Unit\SaveHandler\Redis; +use Magento\Store\Model\ScopeInterface; use Magento\Framework\Session\SaveHandler\Redis\Config; class ConfigTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\App\DeploymentConfig + * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */ - protected $deploymentConfig; + private $deploymentConfigMock; /** - * @var \Magento\Framework\App\State + * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */ - protected $appState; + private $appStateMock; /** - * @var \Magento\Framework\Session\SaveHandler\Redis\Config + * @var \Magento\Framework\App\Config|\PHPUnit_Framework_MockObject_MockObject */ - protected $config; + private $scopeConfigMock; + + /** + * @var Config + */ + private $config; public function setUp() { - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->appStateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false); + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->config = $objectManager->getObject( - 'Magento\Framework\Session\SaveHandler\Redis\Config', + Config::class, [ - 'deploymentConfig' => $this->deploymentConfig, - 'appState' => $this->appState + 'deploymentConfig' => $this->deploymentConfigMock, + 'appState' => $this->appStateMock, + 'scopeConfig' => $this->scopeConfigMock ] ); } @@ -41,7 +50,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetLogLevel() { $expected = 2; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_LOG_LEVEL) ->willReturn($expected); @@ -51,7 +60,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetHost() { $expected = '127.0.0.1'; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_HOST) ->willReturn($expected); @@ -61,7 +70,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetPort() { $expected = 1234; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_PORT) ->willReturn($expected); @@ -71,7 +80,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetDatabase() { $expected = 2; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_DATABASE) ->willReturn($expected); @@ -81,7 +90,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetPassword() { $expected = 'password'; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_PASSWORD) ->willReturn($expected); @@ -91,7 +100,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetTimeout() { $expected = 10; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_TIMEOUT) ->willReturn($expected); @@ -101,7 +110,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetPersistentIdentifier() { $expected = 'sess01'; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_PERSISTENT_IDENTIFIER) ->willReturn($expected); @@ -111,7 +120,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetCompressionThreshold() { $expected = 2; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_COMPRESSION_THRESHOLD) ->willReturn($expected); @@ -121,7 +130,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetCompressionLibrary() { $expected = 'gzip'; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_COMPRESSION_LIBRARY) ->willReturn($expected); @@ -131,7 +140,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetMaxConcurrency() { $expected = 6; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_MAX_CONCURRENCY) ->willReturn($expected); @@ -140,18 +149,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetMaxLifetime() { - $expected = 30; - $this->deploymentConfig->expects($this->once()) - ->method('get') - ->with(Config::PARAM_MAX_LIFETIME) - ->willReturn($expected); - $this->assertEquals($this->config->getMaxLifetime(), $expected); + $this->assertEquals($this->config->getMaxLifetime(), Config::SESSION_MAX_LIFETIME); } public function testGetMinLifetime() { $expected = 30; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_MIN_LIFETIME) ->willReturn($expected); @@ -161,7 +165,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetDisableLocking() { $expected = false; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_DISABLE_LOCKING) ->willReturn($expected); @@ -171,7 +175,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetBotLifetime() { $expected = 30; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_BOT_LIFETIME) ->willReturn($expected); @@ -181,7 +185,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetBotFirstLifetime() { $expected = 30; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_BOT_FIRST_LIFETIME) ->willReturn($expected); @@ -191,7 +195,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetFirstLifetime() { $expected = 30; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_FIRST_LIFETIME) ->willReturn($expected); @@ -202,13 +206,44 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $areaCode = 'frontend'; $breakAfter = 5; - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfigMock->expects($this->once()) ->method('get') ->with(Config::PARAM_BREAK_AFTER . '_' . $areaCode) ->willReturn($breakAfter); - $this->appState->expects($this->once()) + $this->appStateMock->expects($this->once()) ->method('getAreaCode') ->willReturn($areaCode); $this->assertEquals($this->config->getBreakAfter(), $breakAfter); } + + public function testGetLifetimeAdmin() + { + $areaCode = 'adminhtml'; + $expectedLifetime = 123; + $this->appStateMock->expects($this->once()) + ->method('getAreaCode') + ->willReturn($areaCode); + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with(Config::XML_PATH_ADMIN_SESSION_LIFETIME) + ->willReturn($expectedLifetime); + $this->assertEquals($this->config->getLifetime(), $expectedLifetime); + } + + public function testGetLifetimeFrontend() + { + $areaCode = 'frontend'; + $expectedLifetime = 234; + $this->appStateMock->expects($this->once()) + ->method('getAreaCode') + ->willReturn($areaCode); + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with( + Config::XML_PATH_COOKIE_LIFETIME, + ScopeInterface::SCOPE_STORE + ) + ->willReturn($expectedLifetime); + $this->assertEquals($this->config->getLifetime(), $expectedLifetime); + } }