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

hotline #28245 Fix random displaying of critics: add tests

parent 300ff4ff
Branches
Tags
4 merge requests!1046Master,!1045Hotline master,!1044Stable,!1036Hotline#28245 fix random displaying of critics
......@@ -100,9 +100,6 @@ class BlogController extends ZendAfi_Controller_Action {
$avis = Class_AvisNotice::getAvisFromPreferences($preferences,[$this->view->page, $this->view->config['nb_display']]);
if (isset($preferences['display_order']) && $preferences['display_order'] == 'Random')
shuffle($avis);
$this->view->liste_avis = $avis;
$params_url=$this->_request->getParams();
......
......@@ -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,6 +38,7 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_
$fetched_avis = Class_AvisNotice::getAvisFromPreferences($this->getPreferences());
if ($this->getPreference('display_order') == 'Random')
shuffle($fetched_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