diff --git a/VERSIONS_HOTLINE/53821 b/VERSIONS_HOTLINE/53821 new file mode 100644 index 0000000000000000000000000000000000000000..a66f1ce8ee60fdd242c04bc61ca745bc66e44c8e --- /dev/null +++ b/VERSIONS_HOTLINE/53821 @@ -0,0 +1 @@ + - ticket #53821 : lorsqu'on réserve depuis le résultat de recherche et que la réservation est impossible, les critères de recherche initiaux sont gardés \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 6a7b0611b63fc898cac2350932cc48828f5a2303..62b2893720355570d4cb9842237d1ebb30c82b2d 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -81,19 +81,34 @@ class RechercheController extends ZendAfi_Controller_Action { return; } - $search_start_time = microtime(true); - $criteres_recherche = $this->newCriteresRecherches($params); if ($this->view->statut == 'guidee') $criteres_recherche->updateRubrique('guidee'); + if ($this->_request->isPost()) { + $params = $criteres_recherche->getUrlCriteresWithFacettes(); + // preserve module as we may come from Telephone_RechercheController + $params['module'] = $this->_request->getModuleName(); + return $this->_redirect($this->view->url($params, null, true), + ['prependBase' => false]); + } + + $this->getFrontController()->getRouter()->getCurrentRoute() + ->match(str_replace(BASE_URL, + '', + $this->view->url($criteres_recherche->getCriteres()))); + + $this->_runSearchAndRender($criteres_recherche); + } + + + protected function _runSearchAndRender($criteres_recherche) { + $search_start_time = microtime(true); + $search_result = $this->moteur->lancerRecherche($criteres_recherche); - if (($ig = Zend_Controller_Front::getInstance() - ->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget')) - && $ig->isEnabled()) - $ig->logRecord($this->view->searchInspector($this->moteur)); + $this->_logSearch(); if ('json' == $this->_getParam('format', '')) return $this->_renderJsonResult($search_result); @@ -101,27 +116,30 @@ class RechercheController extends ZendAfi_Controller_Action { if ('atom' == $this->_getParam('format', '')) return $this->_renderAtomResult($search_result); - $this->getFrontController()->getRouter()->getCurrentRoute() - ->match(str_replace(BASE_URL, - '', - $this->view->url($criteres_recherche->getCriteres()))); + $this->preferences['liste_format'] = $this->_getParam('liste_format', $this->preferences['liste_format']); + + if (!$search_result->isError()) + $this->addHistoRecherche(1, $criteres_recherche); $this->view->titre = $this->getTitreRechercheSimple($criteres_recherche); if($criteres_recherche->getPertinence()) $this->view->titre .= $this->_(' (recherche élargie triée par pertinence)'); - $this->preferences['liste_format'] = $this->_getParam('liste_format', $this->preferences['liste_format']); - - if (!$search_result->isError()) - $this->addHistoRecherche(1, $criteres_recherche); - $this->view->search_result = $search_result ->setDuration(microtime(true) - $search_start_time) ->setSettings($this->preferences); } + protected function _logSearch() { + if (($ig = Zend_Controller_Front::getInstance() + ->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget')) + && $ig->isEnabled()) + $ig->logRecord($this->view->searchInspector($this->moteur)); + } + + protected function _extractMultifacetsPost() { if (!$this->_request->isPost()) return; diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index 48fb3b8be0faf09b761c94e887dcbffb27beb59b..2386ae20fdc4f28c17bf45e8585368e2b9f6ce92 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -40,10 +40,12 @@ class RechercheControllerPrintActionLinkTest extends AbstractControllerTestCase ->whenCalled('fetchAll') ->with("select id_notice, facettes from notices Where MATCH(facettes) AGAINST('+(APaul)' IN BOOLEAN MODE) order by annee desc", true, false) ->answers([ [1, ''] ]) + ->whenCalled('fetchAll') ->answers([$this->fixture('Class_Notice', ['id' => 1])->toArray()]) ->beStrict(); + Zend_Registry::set('sql', $mock_sql); $this->dispatch('/recherche/simple/id_catalogue/3/id_module/9/aleatoire/1', true); } @@ -51,7 +53,7 @@ class RechercheControllerPrintActionLinkTest extends AbstractControllerTestCase /** @test */ public function printLinkShouldBePresent() { - $this->assertXPathContentContains('//a[contains(@href, "/recherche/print/id_catalogue/3/id_module/9/aleatoire/1/filtres/APaul%3B/ids/1/strategy/Notice_List/modele_fusion/1")][@target="_blank"]', + $this->assertXPathContentContains('//a[contains(@href, "/recherche/print/id_catalogue/3/id_module/9/aleatoire/1/ids/1/strategy/Notice_List/modele_fusion/1")][@target="_blank"]', 'Imprimer', $this->_response->getBody()); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index ff3bcd0a0693b6f2505fa133096b48baa3986b49..cd7a281e65ffd1aff139b9780c0103d2b549e089 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -3380,8 +3380,7 @@ class RechercheControllerMultiFacettesTest extends RechercheControllerNoticeTest ->whenCalled('fetchAll') ->answers([ [$this->notice->getId(), $this->notice->getFacettes()] ]); - $this->postDispatch('/recherche/simple', - ['expressionRecherche' => 'pomme']); + $this->dispatch('/recherche/simple/expressionRecherche/pomme'); $this->assertXPath('//div[@class="facette"]/form[@method="POST"][@action="/recherche/simple/expressionRecherche/pomme"]'); } @@ -3394,6 +3393,14 @@ class RechercheControllerMultiFacettesTest extends RechercheControllerNoticeTest } + /** @test */ + public function postQueryWithoutMultifacetsShouldRedirectToZendFormedUrl() { + $this->postDispatch('/recherche/simple', + ['expressionRecherche' => 'pear']); + $this->assertRedirectTo('/recherche/simple/expressionRecherche/pear'); + } + + /** @test */ public function activeFacetsShouldBeT3() { $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/*/multifacets/T3'); diff --git a/tests/application/modules/telephone/controllers/RechercheControllerTest.php b/tests/application/modules/telephone/controllers/RechercheControllerTest.php index 60054c2aebf418d04fd3a8e277a9ea4fe2dfbe0c..4a424b425341425a43929efe2aae0f314824fff8 100644 --- a/tests/application/modules/telephone/controllers/RechercheControllerTest.php +++ b/tests/application/modules/telephone/controllers/RechercheControllerTest.php @@ -58,23 +58,26 @@ class Telephone_RechercheControllerSimpleSeveralInexistingWordsActionTest extend class Telephone_RechercheControllerSimpleOneInexistingWordActionTest extends TelephoneAbstractControllerTestCase { - public function setUp() { - parent::setUp(); - $this->postDispatch('/telephone/recherche/simple', - array('expressionRecherche' => 'zzriuezz')); - } - - /** @test */ public function pageShouldNotContainsLinkToElargirLaRecherche() { + $this->dispatch('/telephone/recherche/simple/expressionRecherche/zzriuezz', true); $this->assertNotXPath('//a[contains(@href, "recherche/simple/pertinence/1")]'); } /** @test */ public function pageShouldDisplayAucunResultat() { + $this->dispatch('/telephone/recherche/simple/expressionRecherche/zzriuezz', true); $this->assertXPathContentContains('//div', 'Aucun résultat trouvé'); } + + + /** @test */ + public function postShouldRedirect() { + $this->postDispatch('/telephone/recherche/simple/', + ['expressionRecherche' => 'zzriuezz']); + $this->assertRedirectTo('/telephone/recherche/simple/expressionRecherche/zzriuezz'); + } }