diff --git a/application/modules/opac/controllers/SitoController.php b/application/modules/opac/controllers/SitoController.php index 767cff1bce9e79513cdaf750b39cbcd7d65742b0..b5a0a6eb072928990bb8d1f7128d910ed3f76d76 100644 --- a/application/modules/opac/controllers/SitoController.php +++ b/application/modules/opac/controllers/SitoController.php @@ -107,7 +107,6 @@ class SitoController extends Zend_Controller_Action { $helper = new ZendAfi_View_Helper_Accueil_Sito($id_module, $module_params); $helper->setPage($page); $helper->setView($this->view); - $helper->disableCache(); $this->view->sito_helper = $helper; $viewRenderer = $this->getHelper('ViewRenderer'); diff --git a/library/ZendAfi/View/Helper/Accueil/Sito.php b/library/ZendAfi/View/Helper/Accueil/Sito.php index ee340700e3b56071c55adb73832e146cff113ac0..642bc18cf97980e90256fc21fc5013567090c9cc 100644 --- a/library/ZendAfi/View/Helper/Accueil/Sito.php +++ b/library/ZendAfi/View/Helper/Accueil/Sito.php @@ -27,7 +27,7 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base const DISPLAY_GROUPED = 2; const DISPLAY_HIERARCHY = 3; - protected $strategy, $page, $disable_cache = false; + protected $strategy, $page; protected function _renderHeadScriptsOn($script_loader) { $this->getStrategy()->renderHeadScriptsOn($script_loader); @@ -35,9 +35,9 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base public function shouldCacheContent() { - if ($this->disable_cache) - return false; - return parent::shouldCacheContent(); + return $this->isTypeAffichagePaged() + ? false + : parent::shouldCacheContent(); } @@ -98,10 +98,6 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base $this->page = $page; return $this; } - - public function disableCache() { - $this->disable_cache = true; - } } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php index d2a2eeaef84b3ff33e497d2277c15e9bd942c5ff..bb4c7e962b8917e31b4a58c8938540cb5e6c75b4 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php @@ -33,6 +33,12 @@ abstract class SitoViewHelperTestCase extends ViewHelperTestCase { public function setUp() { parent::setUp(); + Storm_Cache::beVolatile(); + $this->fixture('Class_AdminVar', + ['id' => 'CACHE_ACTIF', + 'valeur' => '1' + ]); + Class_AdminVar::newInstanceWithId('BLUGA_API_KEY', ['valeur' => ''])->save(); $this->_belgique = $this->fixture('Class_SitothequeCategorie', @@ -188,6 +194,42 @@ class SitoViewHelperSelectItemsBySelectionOrderPaginationTest extends SitoViewHe +class SitoViewHelperWithoutCacheTest extends SitoViewHelperTestCase { + protected $_preferences = ['titre' => 'Ma sito', + 'type_aff' => 1, + 'id_items' => '12-15', + 'id_categorie' => '', + 'nb_aff' => 1, + 'display_order' => 'Selection']; + + /** @test */ + public function cacheShouldNotBeUse() { + $value = (new Storm_Cache())->getCache()->load('b0ca57808f9be79c82d794dd6ff37979'); + $this->assertFalse($value); + } +} + + + + +class SitoViewHelperCachedTest extends SitoViewHelperTestCase { + protected $_preferences = ['titre' => 'Ma sito', + 'type_aff' => 2, + 'id_items' => '12-15', + 'id_categorie' => '', + 'nb_aff' => 1, + 'display_order' => 'Selection']; + + /** @test */ + public function cacheShouldBeUse() { + $value = (new Storm_Cache())->getCache()->load('7d8b4403c83a27920e6e1767ee9132e5'); + $this->assertNotEquals(false, $value); + } +} + + + + class SitoViewHelperSelectItemsByRandomOrderTest extends SitoViewHelperTestCase { protected $_preferences = ['titre' => 'Ma sito', 'type_aff' => 1,