/**
  * @dataProvider loadProvider
  * @param mixed $expected
  * @param string $id
  * @param mixed $cache
  * @param bool $isGet
  * @param bool $isHead
  */
 public function testLoad($expected, $id, $cache, $isGet, $isHead)
 {
     $this->requestMock->expects($this->once())->method('isGet')->will($this->returnValue($isGet));
     $this->requestMock->expects($this->any())->method('isHead')->will($this->returnValue($isHead));
     $this->fullPageCacheMock->expects($this->any())->method('load')->with($this->equalTo($id))->will($this->returnValue(serialize($cache)));
     $this->identifierMock->expects($this->any())->method('getValue')->will($this->returnValue($id));
     $this->assertEquals($expected, $this->kernel->load());
 }
예제 #2
0
 /**
  * @param \Magento\Framework\App\FrontControllerInterface $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\Response\Http
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Framework\App\FrontControllerInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     if (!$this->config->isEnabled() || $this->config->getType() != \Magento\PageCache\Model\Config::BUILT_IN) {
         return $proceed($request);
     }
     $this->version->process();
     $result = $this->kernel->load();
     if ($result === false) {
         $result = $proceed($request);
         if ($result instanceof ResponseHttp) {
             $this->addDebugHeaders($result);
             $this->kernel->process($result);
         }
     } else {
         $this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'HIT', true);
     }
     return $result;
 }
예제 #3
0
 /**
  * @param \Magento\Framework\App\FrontControllerInterface $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  * @return false|\Magento\Framework\App\Response\Http
  */
 public function aroundDispatch(\Magento\Framework\App\FrontControllerInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     if ($this->config->getType() == \Magento\PageCache\Model\Config::BUILT_IN && $this->config->isEnabled()) {
         $this->version->process();
         $response = $this->kernel->load();
         if ($response === false) {
             $response = $proceed($request);
             $cacheControl = $response->getHeader('Cache-Control')['value'];
             $this->addDebugHeader($response, 'X-Magento-Cache-Control', $cacheControl);
             $this->kernel->process($response);
             $this->addDebugHeader($response, 'X-Magento-Cache-Debug', 'MISS');
         } else {
             $this->addDebugHeader($response, 'X-Magento-Cache-Debug', 'HIT');
         }
     } else {
         return $response = $proceed($request);
     }
     return $response;
 }