From c742d25a0ab0869a571ec9500c22be556bcb9db3 Mon Sep 17 00:00:00 2001 From: BibLibre Sysop <sysop@biblibre.com> Date: Thu, 25 Oct 2018 14:53:08 +0200 Subject: [PATCH] hotline #80939 records search selection now correctly check default page size in search module parameters --- VERSIONS_HOTLINE/80939 | 1 + library/Class/MoteurRecherche.php | 1 + .../Controller/Action/Helper/SearchRecords.php | 11 ++++++++--- .../SearchSelection/SearchSelectionTest.php | 18 ++++++++++++++---- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 VERSIONS_HOTLINE/80939 diff --git a/VERSIONS_HOTLINE/80939 b/VERSIONS_HOTLINE/80939 new file mode 100644 index 00000000000..b021d2a705a --- /dev/null +++ b/VERSIONS_HOTLINE/80939 @@ -0,0 +1 @@ + - ticket #80939 : la sélection multiple de notices par page prend correctement en compte la taille de page par défaut définie dans les options du résultat de recherche \ No newline at end of file diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index b92dd84ecfd..bfa75f77856 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -473,6 +473,7 @@ class Class_MoteurRecherche { public function lancerRecherche($criteres_recherche) { + xdebug_break(); $this->visitSearchSettings($criteres_recherche); $search_result = new Class_MoteurRecherche_Result($this, $criteres_recherche); diff --git a/library/ZendAfi/Controller/Action/Helper/SearchRecords.php b/library/ZendAfi/Controller/Action/Helper/SearchRecords.php index c2351879280..557c79431f7 100644 --- a/library/ZendAfi/Controller/Action/Helper/SearchRecords.php +++ b/library/ZendAfi/Controller/Action/Helper/SearchRecords.php @@ -21,9 +21,14 @@ class ZendAfi_Controller_Action_Helper_SearchRecords extends Zend_Controller_Action_Helper_Abstract { - public function searchRecords() { - $criteria = (new Class_CriteresRecherche()) - ->setParams($this->getRequest()->getParams()); + public function searchRecords($preferences = []) { + $criteria = (new Class_CriteresRecherche())->setParams($this->getRequest()->getParams()); + + $preferences = Class_Profil::getCurrentProfil() + ->getCfgModulesPreferences('recherche', 'resultat', 'simple'); + + if (isset($preferences['liste_nb_par_page'])) + $criteria->setDefaultPageSize($preferences['liste_nb_par_page']); return Class_MoteurRecherche::getInstance() ->lancerRecherche($criteria); diff --git a/tests/scenarios/SearchSelection/SearchSelectionTest.php b/tests/scenarios/SearchSelection/SearchSelectionTest.php index cedd474ccd0..6517e46c76f 100644 --- a/tests/scenarios/SearchSelection/SearchSelectionTest.php +++ b/tests/scenarios/SearchSelection/SearchSelectionTest.php @@ -292,16 +292,26 @@ class SearchSelectionSelectClearTest extends SearchSelectionTestCase { class SearchSelectionSelectPageTest extends SearchSelectionTestCase { - public function setUp() { - parent::setUp(); + /** @test */ + public function withTwoRecordsInSessionAndPageSizeTwoSelectShouldAddRecordNine() { Zend_Registry::get('session')->search_record_selection = [8, 10]; $this->dispatch('/records/select-page/expressionRecherche/pomme/facettes/T3/page/1/page_size/2', true); + $this->assertEquals([8, 10, 9], + Zend_Registry::get('session')->search_record_selection); + return $this->_response->getBody(); } /** @test */ - public function sessionShouldContainsNine() { - $this->assertEquals([8, 10, 9], + public function withEmptySessionAndDefaultPageSizeTwoSelectShouldAddEightAndNine() { + Zend_Registry::get('session')->search_record_selection = []; + Class_Profil::getCurrentProfil()->setCfgModulesPreferences(['liste_nb_par_page' => 2], + 'recherche', + 'resultat', + 'simple'); + + $this->dispatch('/records/select-page/expressionRecherche/pomme/facettes/T3/page/1', true); + $this->assertEquals([8, 9], Zend_Registry::get('session')->search_record_selection); return $this->_response->getBody(); } -- GitLab