public function testAroundResultWithPluginDeveloperMode()
 {
     $this->registry->expects($this->once())->method('registry')->with('use_page_cache_plugin')->willReturn(true);
     $this->state->expects($this->once())->method('getMode')->willReturn(\Magento\Framework\App\State::MODE_DEVELOPER);
     $this->header->expects($this->any())->method('getFieldValue')->willReturnOnConsecutiveCalls('test', 'tag,tag2');
     $this->response->expects($this->any())->method('setHeader')->withConsecutive(['X-Magento-Cache-Control', 'test'], ['X-Magento-Cache-Debug', 'MISS', true], ['X-Magento-Tags', 'tag,tag2,' . \Magento\PageCache\Model\Cache\Type::CACHE_TAG]);
     $this->response->expects($this->once())->method('clearHeader')->with('X-Magento-Tags');
     $this->registry->expects($this->once())->method('registry')->with('use_page_cache_plugin')->will($this->returnValue(true));
     $this->kernel->expects($this->once())->method('process')->with($this->response);
     $result = call_user_func($this->closure);
     $this->assertSame($result, $this->plugin->aroundRenderResult($this->subject, $this->closure, $this->response));
 }
예제 #2
0
 /**
  * @dataProvider dataProvider
  */
 public function testAroundDispatchReturnsCache($state)
 {
     $this->configMock->expects($this->once())->method('getType')->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN));
     $this->configMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
     $this->versionMock->expects($this->once())->method('process');
     $this->kernelMock->expects($this->once())->method('load')->will($this->returnValue($this->responseMock));
     $this->stateMock->expects($this->any())->method('getMode')->will($this->returnValue($state));
     if ($state == \Magento\Framework\App\State::MODE_DEVELOPER) {
         $this->responseMock->expects($this->once())->method('setHeader')->with('X-Magento-Cache-Debug');
     } else {
         $this->responseMock->expects($this->never())->method('setHeader');
     }
     $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock);
 }