Example #1
0
 public function testGetCacheKeyInfo()
 {
     $info = $this->_block->getCacheKeyInfo();
     $keys = array_keys($info);
     /** order and values of cache key info elements is important */
     $this->assertSame(0, array_shift($keys));
     $this->assertEquals('CATALOG_PRODUCT_NEW', $info[0]);
     $this->assertSame(1, array_shift($keys));
     $this->assertEquals(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getId(), $info[1]);
     $this->assertSame(2, array_shift($keys));
     $themeModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface')->getDesignTheme();
     $this->assertEquals($themeModel->getId() ?: null, $info[2]);
     $this->assertSame(3, array_shift($keys));
     $this->assertEquals(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Customer\\Model\\Session')->getCustomerGroupId(), $info[3]);
     $this->assertSame('template', array_shift($keys));
     /**
      * This block is implemented without template by default (invalid).
      * Having the cache key fragment with empty value can potentially lead to caching bugs
      */
     $this->assertSame(4, array_shift($keys));
     $this->assertNotEquals('', $info[4]);
 }
Example #2
0
 /**
  * Get key pieces for caching block content
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     return array_merge(parent::getCacheKeyInfo(), [$this->getDisplayType(), $this->getProductsPerPage(), intval($this->getRequest()->getParam($this->getData('page_var_name'), 1)), serialize($this->getRequest()->getParams())]);
 }
 /**
  * Get key pieces for caching block content
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     return array_merge(parent::getCacheKeyInfo(), [$this->getDisplayType(), $this->getProductsPerPage(), intval($this->getRequest()->getParam(self::PAGE_VAR_NAME))]);
 }