From ac9faf77d18206034918f90a7947416705fc8fee Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-loas.afi-sa.net> Date: Mon, 17 Feb 2014 11:25:28 +0100 Subject: [PATCH] rel #9995 correction of regression number of records displayed by page --- .../opac/controllers/NoticeajaxController.php | 8 ++--- library/Class/Notice.php | 2 +- .../Form/Configuration/SearchResult.php | 4 +-- .../controllers/NoticeAjaxControllerTest.php | 33 ++++++++++++++++--- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index f5d788f35bf..7d4a5ef6e04 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -479,11 +479,11 @@ class NoticeAjaxController extends Zend_Controller_Action { $cvs = Class_CVSLink::forUser($user); $notices = $cvs->searchNotices($query,$criteres_recherche->getPage(),$this->preferences['cvs_nb_result']); - $nb_notices = $cvs->getTotalNotices(); + $nb_total_cvs_records = $cvs->getTotalNotices(); $helper = $this->view->getHelper('ListeCVSNotices'); $html = "<script>"; - if ($nb_notices) + if ($nb_total_cvs_records) $html .= "$('.cvs_container:hidden').slideDown('slow');"; $html .= "$(document).ready(function(){ $('#cvs_result .pager a').click(function(e){ @@ -496,11 +496,11 @@ class NoticeAjaxController extends Zend_Controller_Action { });</script><div id='cvs_result'>"; $html .= $helper->listeCVSNotices($notices, - $nb_notices, + $nb_total_cvs_records, $criteres_recherche->getPage(), $this->preferences); - $html .= $this->view->pager($cvs->getTotalNotices(), + $html .= $this->view->pager($nb_total_cvs_records, $this->preferences['cvs_nb_result'], $criteres_recherche->getPage(), $this->view->url(['controller' => 'noticeajax', diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 7b6278dcca9..72d1b4e23a4 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -785,7 +785,7 @@ class Class_Notice extends Storm_Model_Abstract { public function getChamp856b() { $data = $this->get_subfield(856, "b"); - return $data[0]; + return isset($data[0]) ? $data[0] : ''; } diff --git a/library/ZendAfi/Form/Configuration/SearchResult.php b/library/ZendAfi/Form/Configuration/SearchResult.php index c8628a143a3..dcd1d927f97 100644 --- a/library/ZendAfi/Form/Configuration/SearchResult.php +++ b/library/ZendAfi/Form/Configuration/SearchResult.php @@ -217,7 +217,7 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { ['label' => $this->_('Titre résultat recherche'), 'size' => $this->_text_size]) ->addElement('text', - 'cvs_nb_resultats', + 'cvs_nb_result', ['label' => $this->_('Nombre de résultats à afficher'), 'size' => $this->_num_size]) ->addElement('text', @@ -246,7 +246,7 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { $this->addDisplayGroup(['cvs_display_position', 'cvs_resultat_titre', 'cvs_autres_resultats', - 'cvs_nb_resultats', + 'cvs_nb_result', 'cvs_msg_deco', 'cvs_msg_droit'], 'cvs', diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index a502c84c969..2dd2533aaf0 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -1012,27 +1012,36 @@ class NoticeAjaxControllerCvsSearchWithNoRecordTest extends NoticeAjaxController class NoticeAjaxControllerCvsWithRecordsSearchTest extends NoticeAjaxControllerCvsSearchtest { protected $_cvs; + protected $_http_client; + public function setUp() { parent::setUp(); + + Class_Profil::getCurrentProfil() + ->setCfgModules(['recherche' => + ['resultatsimple' => [ 'cvs_display_position' => '1', + 'liste_format' => 3, + 'cvs_nb_result' => 2]]]); + RessourcesNumeriquesFixtures::activateCVS(); $record = $this->fixture('Class_Notice',['id'=> 10, 'titre_principal' => 'Le photographe', 'auteur_principal' => 'Guibert']); $this->_cvs = Class_CVSLink::forUser($record); - $http_client = Storm_Test_ObjectWrapper::mock(); + $this->_http_client = Storm_Test_ObjectWrapper::mock(); Class_CVSLink::setTimeSource((new TimeSourceForTest)->setTime(1369640315)); - Class_CVSLink::setDefaultHttpClient($http_client); - Class_Xml::setDefaultHttpClient($http_client); + Class_CVSLink::setDefaultHttpClient($this->_http_client); + Class_Xml::setDefaultHttpClient($this->_http_client); RessourcesNumeriquesFixtures::activateCVS(); - $http_client + $this->_http_client ->whenCalled('postData') ->answers($this->_returnedXML()) ; - $this->dispatch('/opac/noticeajax/cvs-search/expressionRecherche/Cuisson/page/2', true); + $this->dispatch('/opac/noticeajax/cvs-search/expressionRecherche/Cuisson/page/1', true); } @@ -1046,6 +1055,20 @@ class NoticeAjaxControllerCvsWithRecordsSearchTest extends NoticeAjaxControllerC public function simpleContentShouldContainsCVSDiv() { $this->assertXPath('//div[@id="cvs_result"]//div[@class="cvs_record_list"]', $this->_response->getBody()); } + + + /** @test **/ + public function resultFormatShouldBeVignetteMode() { + $this->assertXPath('//div[@class="liste_vignettes"]'); + } + + + /** @test **/ + public function cvsSearchRequestShouldHaveNbParPage2() { + $xml= base64_decode(strtr($this->_http_client->getAttributesForLastCallOn('postData')[1]['xml'], '-_', '+/')); + $xpath = new Storm_Test_XPathXML(); + $xpath->assertXPath($xml,'//nombre_par_page[contains(text(),2)]'); + } } -- GitLab