/** * Render tag manager script * * @return string */ protected function _toHtml() { if ($this->_cookieHelper->isUserNotAllowSaveCookie() || !$this->_gtmHelper->isEnabled()) { return ''; } return parent::_toHtml(); }
public function testGetCookieRestrictionLifetime() { $this->_request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getCookie'], [], '', false, false); $scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $storeStub = $this->_getStoreStub(); $scopeConfig->expects($this->once())->method('getValue')->will($this->returnCallback([$this, 'getConfigMethodStub']))->with($this->equalTo('web/cookie/cookie_restriction_lifetime')); $this->_context = $this->getMock('Magento\\Framework\\App\\Helper\\Context', ['getRequest', 'getScopeConfig'], [], '', false, false); $this->_context->expects($this->once())->method('getRequest')->will($this->returnValue($this->_request)); $this->_context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); $this->_object = new \Magento\Cookie\Helper\Cookie($this->_context, $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false, false), ['current_store' => $storeStub, 'website' => $this->_getWebsiteStub()]); $this->assertEquals($this->_object->getCookieRestrictionLifetime(), 60 * 60 * 24 * 365); }