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(Mage::app()->getStore()->getId(), $info[1]); $this->assertSame(2, array_shift($keys)); $this->assertEquals(Mage_Core_Model_Theme::CACHE_TAG_NO_THEME, $info[2]); $this->assertSame(3, array_shift($keys)); $this->assertEquals(Mage::getSingleton('Mage_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]); }
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(Mage::app()->getStore()->getId(), $info[1]); $this->assertSame(2, array_shift($keys)); $this->assertEquals(Mage::getDesign()->getPackageName(), $info[2]); $this->assertSame(3, array_shift($keys)); $this->assertEquals(Mage::getDesign()->getTheme(), $info[3]); $this->assertSame(4, array_shift($keys)); $this->assertNotEquals('', $info[4]); $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(5, array_shift($keys)); $this->assertNotEquals('', $info[5]); }
/** * Get key pieces for caching block content * * @return array */ public function getCacheKeyInfo() { return array_merge(parent::getCacheKeyInfo(), array($this->getDisplayType(), $this->getProductsPerPage(), intval($this->getRequest()->getParam(self::PAGE_VAR_NAME)))); }
/** * Returns array that uniquely identifies this product list in cache storage * * @return array Cache key info * @throws Mage_Core_Exception */ public function getCacheKeyInfo() { /* get Magento's standard cache key info */ $cacheKeyInfo = parent::getCacheKeyInfo(); return $this->_getDispatcherHelper()->dispatchEvent('catalog_product_new_get_cache_key_info', $cacheKeyInfo, 'cache_key_info'); }