From 6e9b8b9514e78f50f3f5a803de750f4e698a55db Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@afi-sa.fr> Date: Thu, 20 Dec 2018 15:22:33 +0100 Subject: [PATCH] hotline #83536 : add missing return context to records link --- VERSIONS_HOTLINE/83536 | 1 + .../opac/controllers/BlogController.php | 2 +- .../views/scripts/blog/viewcritiques.phtml | 20 ++++++--- .../controllers/AbonneControllerAvisTest.php | 43 ++++++++++++------- 4 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 VERSIONS_HOTLINE/83536 diff --git a/VERSIONS_HOTLINE/83536 b/VERSIONS_HOTLINE/83536 new file mode 100644 index 00000000000..2559845b729 --- /dev/null +++ b/VERSIONS_HOTLINE/83536 @@ -0,0 +1 @@ + - ticket #83536 : Boite Avis : ajout du contexte de retour manquant dans les liens vers les notices \ No newline at end of file diff --git a/application/modules/opac/controllers/BlogController.php b/application/modules/opac/controllers/BlogController.php index 704ad7e8eaa..30f70161364 100644 --- a/application/modules/opac/controllers/BlogController.php +++ b/application/modules/opac/controllers/BlogController.php @@ -102,7 +102,7 @@ class BlogController extends ZendAfi_Controller_Action { public function viewcritiquesAction() { $this->view->page = $this->_getParam('page', 1); - $id_module = (int)$this->_getParam('id_module'); + $this->view->id_module = $id_module = (int)$this->_getParam('id_module'); $profil = Class_Profil::getCurrentProfil(); $preferences = $profil->getModuleAccueilPreferences($id_module, 'CRITIQUES'); diff --git a/application/modules/opac/views/scripts/blog/viewcritiques.phtml b/application/modules/opac/views/scripts/blog/viewcritiques.phtml index f2427b4a953..c692cee123a 100644 --- a/application/modules/opac/views/scripts/blog/viewcritiques.phtml +++ b/application/modules/opac/views/scripts/blog/viewcritiques.phtml @@ -1,15 +1,25 @@ <?php $this->openBoite($this->title); -if(is_array($this->liste_avis)) -{ + +if (is_array($this->liste_avis)) { + $helper = $this->getHelper('Avis'); + if ($this->id_module) + $helper->addUrlContext(['retour_avis' => $this->id_module]); + $html_avis = []; foreach($this->liste_avis as $avis) - $html_avis []= $this->avis($avis); + $html_avis []= $helper->avis($avis); + echo implode('<div class="separator"></div>', $html_avis); } -echo BR.'<div align="center" style="width:100%">'.$this->pager($this->total,$this->config['nb_display'],$this->page,$this->params_url ).'</div>'; +echo BR . $this->tag('div', + $this->pager($this->total, + $this->config['nb_display'], + $this->page, + $this->params_url), + ['align' => 'center', + 'style' => 'width:100%s']); $this->closeBoite(); -?> diff --git a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php index a1aff68f680..44fe54f783d 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php @@ -661,14 +661,12 @@ abstract class ModuleSelectionCritiquesTestCase extends AvisControllersFixturesT $preferences = ['modules' => [3 => ['division' => 2, 'type_module' => 'CRITIQUES', - 'preferences' => ['titre' => 'Coups de coeur' - ] - ]]]; + 'preferences' => ['titre' => 'Coups de coeur']]]]; + $profil = $this->fixture('Class_Profil', - ['id'=>2, + ['id' => 2, 'cfg_modules' => ['blog' => ['viewcritiques' => ['nb_display' => 2]]], 'cfg_accueil' => $preferences]); - } } @@ -700,34 +698,49 @@ class AbonneControllerAvisBlogControllerViewCritiquesDefaultTest extends ModuleS } + class AbonneControllerAvisBlogControllerViewCritiquesTest extends ModuleSelectionCritiquesTestCase { public function setUp() { parent::setUp(); $this->dispatch('/opac/blog/viewcritiques/id_profil/2/id_module/3'); } - public function testMilleniumIsHere() { - $this->assertQueryContentContains('h2', 'Millenium',$this->_response->getBody()); + + /** @test */ + public function titleShouldBeCoupsDeCoeur() { + $this->assertXPathContentContains('//h1', 'Coups de coeur'); } - public function testPotterIsHere() { - $this->assertQueryContentContains('h2', 'Potter',$this->_response->getBody()); + + /** @test */ + public function milleniumShouldBeDisplayed() { + $this->assertXPathContentContains('//h2', 'Millenium'); } + /** @test */ - public function pagerShouldBeDisplayed() { - $this->assertXPath('//a[@href="/blog/viewcritiques/id_profil/2/id_module/3/page/2"]', $this->_response->getBody()); + public function milleniumRecordLinkShouldContainsReturnContext() { + $this->assertXPath('//a[contains(@href, "id/817")][contains(@href, "retour_avis/3")]', + $this->_response->getBody()); } + /** @test */ - public function pagerShouldNotContains3Pages() { - $this->assertNotXPath('//a[contains(@href,"/page/3")]', $this->_response->getBody()); + public function potterShouldBeDisplayed() { + $this->assertXPathContentContains('//h2', 'Potter'); } /** @test */ - public function titleShouldBeCoupsDeCoeur() { - $this->assertXPathContentContains('//h1', 'Coups de coeur'); + public function pagerShouldBeDisplayed() { + $this->assertXPath('//a[@href="/blog/viewcritiques/id_profil/2/id_module/3/page/2"]', + $this->_response->getBody()); + } + + + /** @test */ + public function pagerShouldNotContains3Pages() { + $this->assertNotXPath('//a[contains(@href,"/page/3")]', $this->_response->getBody()); } } -- GitLab