Commit 37c81fa6 authored by Laurent's avatar Laurent
Browse files

hotline #65920 kiosk widget: random option fix

parent 0a79c14d
- ticket #65920 : Boites kiosque : correction de la fonction de tirage aléatoire
\ No newline at end of file
...@@ -280,6 +280,10 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba ...@@ -280,6 +280,10 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba
public function getKiosqueHtml($page = 1) { public function getKiosqueHtml($page = 1) {
if ($this->isModeChrono() || (1 === (int)$this->preferences['aleatoire']))
return $this->_noPagerKioskHtml();
$this->_nombre_notices_par_page = $this->preferences['nb_notices']; $this->_nombre_notices_par_page = $this->preferences['nb_notices'];
$nombre_total_notices = 0; $nombre_total_notices = 0;
$this->preferences['nb_notices'] = 0; $this->preferences['nb_notices'] = 0;
...@@ -296,15 +300,20 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba ...@@ -296,15 +300,20 @@ class ZendAfi_View_Helper_Accueil_Kiosque extends ZendAfi_View_Helper_Accueil_Ba
if(!$notices) if(!$notices)
return $this->view->tag('p',$this->view->_('Aucun résultat')); return $this->view->tag('p',$this->view->_('Aucun résultat'));
$html = $this->renderNoticesKiosqueHtml($notices); return
if (!$this->isModeChrono()) $this->getPagerHtml($page,
$html = $this
->getPagerHtml($page,
$this->_nombre_notices_par_page, $this->_nombre_notices_par_page,
$nombre_total_notices) $nombre_total_notices)
. $html; .
$this->renderNoticesKiosqueHtml($notices);
}
protected function _noPagerKioskHtml() {
if (!$records = Class_Catalogue::getNoticesByPreferences($this->preferences))
return $this->view->tag('p',$this->view->_('Aucun résultat'));
return $html; return $this->renderNoticesKiosqueHtml($records);
} }
......
...@@ -105,6 +105,7 @@ class JavaControllerWithKiosqueMurPageTest extends AbstractControllerTestCase { ...@@ -105,6 +105,7 @@ class JavaControllerWithKiosqueMurPageTest extends AbstractControllerTestCase {
'preferences' => ['style_liste' => 'mur', 'preferences' => ['style_liste' => 'mur',
'nb_notices' => 10, 'nb_notices' => 10,
'nb_analyse' => 50, 'nb_analyse' => 50,
'aleatoire' => 0,
'only_img' => 0]]]]; 'only_img' => 0]]]];
Class_Profil::getCurrentProfil()->setCfgAccueil($cfg_accueil); Class_Profil::getCurrentProfil()->setCfgAccueil($cfg_accueil);
...@@ -115,7 +116,7 @@ class JavaControllerWithKiosqueMurPageTest extends AbstractControllerTestCase { ...@@ -115,7 +116,7 @@ class JavaControllerWithKiosqueMurPageTest extends AbstractControllerTestCase {
/** @test */ /** @test */
public function firstControlShouldLinkToPageOne() { public function firstControlShouldLinkToPageOne() {
$this->assertXPath('//div[@class="controls"]/a[1][contains(@href, "java/page/no/1/id_module/1")]', $this->_response->getBody()); $this->assertXPath('//div[@class="controls"]/a[1][contains(@href, "java/page/no/1/id_module/1")]');
} }
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
abstract class ZendAfi_View_Helper_Accueil_KiosqueTestCase extends ViewHelperTestCase { abstract class ZendAfi_View_Helper_Accueil_KiosqueTestCase extends ViewHelperTestCase {
protected $_html; protected
$_html,
$_storm_default_to_volatile = true;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
...@@ -227,11 +229,27 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithPanierAndTriTest extends ZendAfi ...@@ -227,11 +229,27 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithPanierAndTriTest extends ZendAfi
class ZendAfi_View_Helper_Accueil_KiosqueChronoWithCatalogueTest extends ZendAfi_View_Helper_Accueil_KiosqueMurTestCase { class ZendAfi_View_Helper_Accueil_KiosqueChronoWithCatalogueTest extends ZendAfi_View_Helper_Accueil_KiosqueTestCase {
public function getExtraPreferences() { public function getPreferences() {
return ['id_catalogue' => 12, return ['type_module' => 'KIOSQUE',
'style_liste' => 'chrono', 'division' => 3,
'op_hauteur' => 400]; 'preferences' => ['style_liste' => 'chrono',
'id_catalogue' => 12,
'op_hauteur' => 400,
'aleatoire' => 0
]
];
}
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue')
->whenCalled('getNoticesByPreferences')
->answers($this->_notices);
$this->_html = $this->_helper->getKiosqueHtml();
} }
...@@ -240,14 +258,22 @@ class ZendAfi_View_Helper_Accueil_KiosqueChronoWithCatalogueTest extends ZendAfi ...@@ -240,14 +258,22 @@ class ZendAfi_View_Helper_Accueil_KiosqueChronoWithCatalogueTest extends ZendAfi
$this->assertXPath($this->_html, '//div[@class="liste_chrono"][contains(@id,"liste_chrono_")]'); $this->assertXPath($this->_html, '//div[@class="liste_chrono"][contains(@id,"liste_chrono_")]');
} }
/** @test */ /** @test */
public function heightShouldBe400() { public function heightShouldBe400() {
$this->assertContains('"height":400', $this->_html); $this->assertContains('"height":400', $this->_html);
} }
/** @test */
public function pageShouldNotContainsPager() {
$this->assertNotXPath($this->_html, '//div[@class="controls"]');
}
} }
abstract class ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase extends ZendAfi_View_Helper_Accueil_KiosqueTestCase { abstract class ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase extends ZendAfi_View_Helper_Accueil_KiosqueTestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
...@@ -304,7 +330,6 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase extends ZendA ...@@ -304,7 +330,6 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase extends ZendA
class ZendAfi_View_Helper_Accueil_KiosqueRequetesAsRedacteurTest extends ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase { class ZendAfi_View_Helper_Accueil_KiosqueRequetesAsRedacteurTest extends ZendAfi_View_Helper_Accueil_KiosqueRequetesTestCase {
protected $_catalogue_cinema; protected $_catalogue_cinema;
public function setUp() { public function setUp() {
...@@ -615,3 +640,57 @@ class ZendAfi_View_Helper_Accueil_KiosqueWithLinkedRecordsInDomainSetTest extend ...@@ -615,3 +640,57 @@ class ZendAfi_View_Helper_Accueil_KiosqueWithLinkedRecordsInDomainSetTest extend
$this->assertEquals('select id_notice from notices Where MATCH(facettes) AGAINST(\'Q5\' IN BOOLEAN MODE) order by date_creation DESC LIMIT 0,50', $this->_request['req_liste']); $this->assertEquals('select id_notice from notices Where MATCH(facettes) AGAINST(\'Q5\' IN BOOLEAN MODE) order by date_creation DESC LIMIT 0,50', $this->_request['req_liste']);
} }
} }
class ZendAfi_View_Helper_Accueil_WallKioskRandomTest extends ZendAfi_View_Helper_Accueil_KiosqueTestCase {
public function getPreferences() {
return ['type_module' => 'KIOSQUE',
'division' => 3,
'preferences' => ['style_liste' => 'mur',
'id_catalogue' => 12,
'aleatoire' => 1,
'tri' => 1,
'nb_notices' => 20,
'nb_analyse' => 100]
];
}
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue')
->whenCalled('getNoticesByPreferences')
->answers($this->_notices);
$this->_html = $this->_helper->getKiosqueHtml();
}
/** @test */
public function htmlShouldNotContainsPager() {
$this->assertNotXPath($this->_html, '//div[@class="controls"]');
}
/** @test */
public function htmlShouldContainsTwoRecords() {
$this->assertXPathCount($this->_html, '//div[@class="liste_mur"]//div[@class="notice"]',
2,
$this->_html);
}
/** @test */
public function withoutRecordsHtmlShouldContainsNoResult() {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue')
->whenCalled('getNoticesByPreferences')
->answers([]);
$this->assertXPathContentContains($this->_helper->getKiosqueHtml(),
'//p',
utf8_encode('Aucun résultat'));
}
}
Markdown is supported
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