/**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * @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));
 }