/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) { $this->checkoutSession->clearStorage(); } return $result; }
public function testAfterGenerateXmlNoDepersonalize() { $this->catalogSessionMock->expects($this->never())->method('clearStorage'); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false); $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $this->resultLayout); $this->assertEquals($this->resultLayout, $actualResult); }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, \Magento\Framework\View\LayoutInterface $result) { if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) { $this->persistentSession->setCustomerId(null); } return $result; }
public function testAfterGenerateXmlNoDepersonalize() { $expectedResult = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false); $this->checkoutSessionMock->expects($this->never())->method('clearStorage')->will($this->returnValue($expectedResult)); $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult); $this->assertEquals($expectedResult, $actualResult); }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) { $this->customerSession->setDefaultTaxBillingAddress($this->defaultTaxBillingAddress); $this->customerSession->setDefaultTaxShippingAddress($this->defaultTaxShippingAddress); $this->customerSession->setCustomerTaxClassId($this->customerTaxClassId); } return $result; }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) { $this->eventManager->dispatch('depersonalize_clear_session'); session_write_close(); $this->messageSession->clearStorage(); } return $result; }
public function testAfterGenerateXmlNoDepersonalize() { /** @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject $subjectMock */ $subjectMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false, true, true, ['isCacheable']); /** @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject $resultMock */ $resultMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false, true, true, []); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false); $this->persistentSessionMock->expects($this->never())->method('setCustomerId'); $this->assertEquals($resultMock, $this->plugin->afterGenerateXml($subjectMock, $resultMock)); }
/** * @param array $requestResult * @param bool $moduleManagerResult * @param bool $cacheConfigResult * @param bool $layoutResult * @param bool $can Depersonalize * @dataProvider checkIfDepersonalizeDataProvider */ public function testCheckIfDepersonalize(array $requestResult, $moduleManagerResult, $cacheConfigResult, $layoutResult, $canDepersonalize) { $this->requestMock->expects($this->any())->method('isAjax')->willReturn($requestResult['ajax']); $this->requestMock->expects($this->any())->method('isGet')->willReturn($requestResult['get']); $this->requestMock->expects($this->any())->method('isHead')->willReturn($requestResult['head']); $this->moduleManagerMock->expects($this->any())->method('isEnabled')->with('Magento_PageCache')->willReturn($moduleManagerResult); $this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn($cacheConfigResult); $layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false); $layoutMock->expects($this->any())->method('isCacheable')->willReturn($layoutResult); $object = new DepersonalizeChecker($this->requestMock, $this->moduleManagerMock, $this->cacheConfigMock); $this->assertEquals($canDepersonalize, $object->checkIfDepersonalize($layoutMock)); }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) { $this->visitor->setSkipRequestLogging(true); $this->visitor->unsetData(); $this->session->clearStorage(); $this->customerSession->clearStorage(); $this->session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->formKey); $this->customerSession->setCustomerGroupId($this->customerGroupId); $this->customerSession->setCustomer($this->customerFactory->create()->setGroupId($this->customerGroupId)); } return $result; }
public function testAfterGenerateXmlNoDepersonalize() { $expectedResult = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false); $this->visitorMock->expects($this->never())->method('setSkipRequestLogging'); $this->visitorMock->expects($this->never())->method('unsetData'); $this->sessionMock->expects($this->never())->method('clearStorage'); $this->customerSessionMock->expects($this->never())->method('clearStorage'); $this->customerSessionMock->expects($this->never())->method('setCustomerGroupId'); $this->customerMock->expects($this->never())->method('setGroupId'); $this->sessionMock->expects($this->never())->method('setData'); $this->customerSessionMock->expects($this->never())->method('setCustomer'); $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult); $this->assertSame($expectedResult, $actualResult); }