Skip to content
Snippets Groups Projects
Commit 38618e9c authored by Laurent's avatar Laurent
Browse files

Merge branch 'hotline#28245_fix_random_displaying_of_critics' into 'stable'

Hotline#28245 fix random displaying of critics

See merge request !1036
parents a4f04646 c3a00d1c
Branches
Tags
3 merge requests!1046Master,!1045Hotline master,!1044Stable
- ticket #28245: Corrige l'affichage aléatoire des critiques
......@@ -22,6 +22,8 @@
class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_Base {
public function getHtml() {
$this->contenu = '';
if ($this->isHierarchicalDisplay()) {
$this->titre = $this->getPreference('titre');
$this->contenu = $this->view->domainTree($this->getPreference('id_catalogue'),
......@@ -36,7 +38,8 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_
$fetched_avis = Class_AvisNotice::getAvisFromPreferences($this->getPreferences());
if ($this->getPreferences('display_order') == 'Random')
if ($this->getPreference('display_order') == 'Random')
shuffle($fetched_avis);
$selected_avis = [];
......@@ -53,6 +56,7 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_
$selected_avis[] = $avis;
}
if (count($selected_avis) == 0) {
$this->contenu = $this
->decorateContenu($this->_tag('p', $this->_('Aucune critique récente')));
......
......@@ -51,17 +51,19 @@ class CritiquesAvisEmptyTest extends ViewHelperTestCase {
abstract class CritiquesAvisTestCase extends ViewHelperTestCase {
protected $_storm_default_to_volatile = true;
protected $_prefs = []; // subclass responsibility
protected
$_storm_default_to_volatile = true,
$_helper,
$_prefs = []; // subclass responsibility
public function setUp() {
parent::setUp();
$this->_prepareFixtures();
$helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $this->_prefs);
$helper->setView(new ZendAfi_Controller_Action_Helper_View());
$this->html = $helper->getBoite();
$this->_helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $this->_prefs);
$this->_helper->setView(new ZendAfi_Controller_Action_Helper_View());
$this->html = $this->_helper->getBoite();
}
......@@ -169,6 +171,16 @@ class CritiquesWithVignettesTest extends CritiquesAvisTestCase {
}
/** @test */
public function criticsOrderShouldBeRandom() {
Storm_Cache::setDefaultZendCache(null);
$htmls = [];
foreach(range(0, 9) as $i)
$htmls [] = $this->_helper->getBoite();
$this->assertTrue(count(array_unique($htmls)) > 1);
}
/** @test */
public function superLoloCommentWithHtmlShouldBeCutAfterTresBien() {
$this->assertXPathContentContains($this->html, '//p', '
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment