コード例 #1
0
 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));
 }
コード例 #2
0
 /**
  * Run test afterGenerateXml method
  *
  * @param bool $result
  *
  * @dataProvider dataProviderAfterGenerateXml
  */
 public function testAfterGenerateXml($result)
 {
     /** @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->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn($result);
     $this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn($result);
     $this->requestMock->expects($this->any())->method('isAjax')->willReturn(!$result);
     $subjectMock->expects($this->any())->method('isCacheable')->willReturn($result);
     if ($result) {
         $this->persistentSessionMock->expects($this->once())->method('setCustomerId')->with(null);
     } else {
         $this->persistentSessionMock->expects($this->never())->method('setCustomerId')->with(null);
     }
     $this->assertEquals($resultMock, $this->plugin->afterGenerateXml($subjectMock, $resultMock));
 }