27 $this->
_initMock()->_getCookieStub([1 => 1]);
28 $this->assertFalse($this->_object->isUserNotAllowSaveCookie());
29 $request = $this->createPartialMock(\
Magento\Framework\
App\Request\Http::class, [
'getCookie']);
30 $request->expects($this->any())->method(
'getCookie')->will($this->returnValue(json_encode([])));
32 $context = $this->createPartialMock(
34 [
'getRequest',
'getScopeConfig']
36 $context->expects($this->once())->method(
'getRequest')->will($this->returnValue(
$request));
37 $context->expects($this->once())->method(
'getScopeConfig')->will($this->returnValue($scopeConfig));
38 $this->_object = new \Magento\Cookie\Helper\Cookie(
40 $this->createMock(\
Magento\Store\Model\StoreManager::class),
43 $this->assertTrue($this->_object->isUserNotAllowSaveCookie());
48 $this->
_initMock()->_getCookieStub([1 => 1]);
49 $this->assertEquals($this->_object->getAcceptedSaveCookiesWebsiteIds(), json_encode([1 => 1]));
55 $this->createPartialMock(\
Magento\Framework\
App\Request\Http::class, [
'getCookie']);
56 $scopeConfig = $this->createMock(\
Magento\Framework\
App\Config\ScopeConfigInterface::class);
58 $scopeConfig->expects(
63 $this->returnCallback([$this,
'getConfigMethodStub'])
65 $this->equalTo(
'web/cookie/cookie_restriction_lifetime')
67 $this->_context = $this->createPartialMock(
69 [
'getRequest',
'getScopeConfig']
71 $this->_context->expects($this->once())->method(
'getRequest')->will($this->returnValue($this->_request));
72 $this->_context->expects($this->once())->method(
'getScopeConfig')->will($this->returnValue($scopeConfig));
74 $this->_object = new \Magento\Cookie\Helper\Cookie(
76 $this->createMock(\
Magento\Store\Model\StoreManager::class),
79 $this->assertEquals($this->_object->getCookieRestrictionLifetime(), 60 * 60 * 24 * 365);
89 $this->createPartialMock(\
Magento\Framework\
App\Request\Http::class, [
'getCookie']);
90 $this->_context = $this->createPartialMock(
92 [
'getRequest',
'getScopeConfig']
94 $this->_context->expects($this->once())->method(
'getRequest')->will($this->returnValue($this->_request));
95 $this->_context->expects($this->once())->method(
'getScopeConfig')->will($this->returnValue($scopeConfig));
96 $this->_object = new \Magento\Cookie\Helper\Cookie(
98 $this->createMock(\
Magento\Store\Model\StoreManager::class),
110 $store = $this->createMock(\
Magento\Store\Model\Store::class);
121 $scopeConfig = $this->createMock(\
Magento\Framework\
App\Config\ScopeConfigInterface::class);
122 $scopeConfig->expects(
127 $this->returnCallback([$this,
'getConfigMethodStub'])
140 $this->_request->expects(
145 $this->returnValue(json_encode($cookieString))
155 $websiteMock = $this->createMock(\
Magento\Store\Model\Website::class);
157 $websiteMock->expects($this->any())->method(
'getId')->will($this->returnValue(1));
172 'web/cookie/cookie_restriction' => 1,
173 'web/cookie/cookie_restriction_lifetime' => 60 * 60 * 24 * 365,
176 if (array_key_exists($hashName, $defaultConfig)) {
177 return $defaultConfig[$hashName];
180 throw new \InvalidArgumentException(
'Unknow id = ' . $hashName);
testIsUserNotAllowSaveCookie()
testGetAcceptedSaveCookiesWebsiteIds()
testGetCookieRestrictionLifetime()
_getCookieStub($cookieString=[])
getConfigMethodStub($hashName)