/** * Render tag manager script * * @return string */ protected function _toHtml() { if ($this->_cookieHelper->isUserNotAllowSaveCookie() || !$this->_gtmHelper->isEnabled()) { return ''; } return parent::_toHtml(); }
public function testIsUserNotAllowSaveCookie() { $this->_initMock()->_getCookieStub([1 => 1]); $this->assertFalse($this->_object->isUserNotAllowSaveCookie()); $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getCookie'], [], '', false, false); $request->expects($this->any())->method('getCookie')->will($this->returnValue(json_encode([]))); $scopeConfig = $this->_getConfigStub(); $context = $this->getMock('Magento\\Framework\\App\\Helper\\Context', ['getRequest', 'getScopeConfig'], [], '', false, false); $context->expects($this->once())->method('getRequest')->will($this->returnValue($request)); $context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); $this->_object = new \Magento\Cookie\Helper\Cookie($context, $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false, false), ['current_store' => $this->_getStoreStub(), 'website' => $this->_getWebsiteStub()]); $this->assertTrue($this->_object->isUserNotAllowSaveCookie()); }