public function testAfterGenerateXmlNoDepersonalize()
 {
     $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false);
     $this->eventManagerMock->expects($this->never())->method('dispatch');
     $this->messageSessionMock->expects($this->never())->method('clearStorage');
     $expectedResult = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $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->eventManager->dispatch('depersonalize_clear_session');
         session_write_close();
         $this->messageSession->clearStorage();
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * 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->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) {
         $this->eventManager->dispatch('depersonalize_clear_session');
         session_write_close();
         $this->messageSession->clearStorage();
     }
     return $result;
 }
Esempio n. 4
0
 /**
  * Test method afterGenerateXml with enabled module PageCache
  */
 public function testAfterGenerateXmlPageCacheEnabled()
 {
     $expectedResult = $this->getMock('Magento\\Framework\\View\\Layout', array(), array(), '', false);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(true));
     $this->requestMock->expects($this->once($this->once()))->method('isAjax')->will($this->returnValue(false));
     $this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->equalTo('depersonalize_clear_session'));
     $this->messageSessionMock->expects($this->once())->method('clearStorage');
     $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult);
     $this->assertEquals($expectedResult, $actualResult);
 }
Esempio n. 5
0
 public function testAddMessages()
 {
     $messageCollection = $this->getMock('Magento\\Framework\\Message\\Collection', ['getItems', 'addMessage'], [], '', false);
     $this->session->expects($this->any())->method('getData')->will($this->returnValue($messageCollection));
     $this->eventManager->expects($this->once())->method('dispatch')->with('session_abstract_add_message');
     $messageCollection->expects($this->once())->method('addMessage')->with($this->messageMock);
     $this->model->addMessages([$this->messageMock]);
 }