diff --git a/VERSIONS_WIP/dev15606_patron_pickup_library b/VERSIONS_WIP/dev15606_patron_pickup_library new file mode 100644 index 0000000000000000000000000000000000000000..05b2ec958e9631eff47eed9aac3eb82dec15d383 --- /dev/null +++ b/VERSIONS_WIP/dev15606_patron_pickup_library @@ -0,0 +1,2 @@ + - dev#15606: Nanook: possibilité de définir le site de l'abonné comme site de retrait par défaut pour les réservations. + La préférence Cosmogramme 'site_retrait_resa' permet désormais ce comportement, positionnée sur 'site de l'abonné'. diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 6504478b3060d52031b50880a72f522cc5d238b8..14e1f38e1a28ba74ab6819ce6506991366512e55 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -575,11 +575,16 @@ class RechercheController extends ZendAfi_Controller_Action { return; } + $id_bib = (int)$this->_getParam('id_bib'); $id_origine = $this->_getParam('id_origine'); $code_annexe = $this->_getParam('code_annexe'); + if (Class_CosmoVar::isSiteRetraitResaPatronLibrary()) + $code_annexe = $user->getUserIdSite(); + $comm = new Class_CommSigb(); + $ret = $comm->reserverExemplaire($id_bib, $id_origine, $code_annexe); $this->renderPopupResult($this->view->_('Réservation'), @@ -633,7 +638,7 @@ class RechercheController extends ZendAfi_Controller_Action { } - if (!Class_CosmoVar::isSiteRetraitResaEnabled() + if (!Class_CosmoVar::isSiteRetraitResaChoiceEnabled() && !$this->arePickupLocationsProvidedByComm()) { $this->_forward('reservationajax'); return; diff --git a/application/modules/telephone/controllers/RechercheController.php b/application/modules/telephone/controllers/RechercheController.php index 075e1a42ad4c17d4560f0c0434b25b7e52a02a9d..b6078adc8a752c875bc90d969b1311ea97ba3597 100644 --- a/application/modules/telephone/controllers/RechercheController.php +++ b/application/modules/telephone/controllers/RechercheController.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once ROOT_PATH.'application/modules/opac/controllers/RechercheController.php'; @@ -100,7 +100,7 @@ class Telephone_RechercheController extends RechercheController { $this->_loadReservationParamsFromSession(); - if (Class_CosmoVar::isSiteRetraitResaEnabled() + if (Class_CosmoVar::isSiteRetraitResaChoiceEnabled() && !$this->_getParam('pickup')) { $this->_redirect(sprintf('/recherche/pickup-location/b/%s/e/%s/a/%s', urlencode($this->_getParam('b')), @@ -110,8 +110,8 @@ class Telephone_RechercheController extends RechercheController { } $ret = Class_CommSigb::getInstance() - ->reserverExemplaire($this->_getParam('b'), - $this->_getParam('e'), + ->reserverExemplaire($this->_getParam('b'), + $this->_getParam('e'), ($this->_getParam('pickup')) ? $this->_getParam('pickup') : $this->_getParam('a')); if (isset($ret["erreur"]) && '' != $ret['erreur']) { @@ -181,7 +181,7 @@ class Telephone_RechercheController extends RechercheController { public function frbrAction() { - $this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id')); + $this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id')); } @@ -221,4 +221,3 @@ class Telephone_RechercheController extends RechercheController { ->setParam('e', $params['e']) ->setParam('a', $params['a']); }} - diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index c51cc74bdf13f7f18d31dd884562ec7413fd04d4..2cd9c535dbe1579995c46cd10e3ef53164b58aa7 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -2,7 +2,7 @@ // Constantes error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","247"); +define("PATCH_LEVEL","248"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); diff --git a/cosmogramme/sql/patch/patch_248.php b/cosmogramme/sql/patch/patch_248.php new file mode 100644 index 0000000000000000000000000000000000000000..154af7f1b6ff202c6f46393c7898488082ddc841 --- /dev/null +++ b/cosmogramme/sql/patch/patch_248.php @@ -0,0 +1,4 @@ +<?php +Zend_Db_Table::getDefaultAdapter() + ->query("UPDATE `variables` SET commentaire='Site de retrait à la réservation', liste='0:site de l\'exemplaire\r\n1:proposer le choix\r\n2:site de l\'abonné', verrou='' WHERE variables.clef='site_retrait_resa' LIMIT 1;"); +?> diff --git a/library/Class/CommSigb.php b/library/Class/CommSigb.php index ba4ce745ccb7ac1038099fd5df0155c847240631..be57530e68edb76bcfead87cbabcccbb2aa90594 100644 --- a/library/Class/CommSigb.php +++ b/library/Class/CommSigb.php @@ -146,6 +146,18 @@ class Class_CommSigb { return $this->withUserAndSIGBDo($std_user, $supprimer); } + /** + * @param Class_Users $user + * @return array + */ + public function getUserAnnexe($std_user) { + $annexe = function ($user, $sigb) { + return $sigb->getUserAnnexe($user); + }; + + return $this->withUserAndSIGBDo($std_user, $annexe); + } + /** * @param Class_Users $user diff --git a/library/Class/CosmoVar.php b/library/Class/CosmoVar.php index 6ff2276bc1e7b4796406faaf93937d18770e2836..6e1a58b45640fbd4e5a8896da7bf825ed9211b12 100644 --- a/library/Class/CosmoVar.php +++ b/library/Class/CosmoVar.php @@ -32,10 +32,19 @@ class Class_CosmoVarLoader extends Storm_Model_Loader { } - public function isSiteRetraitResaEnabled() { + public function isSiteRetraitResaChoiceEnabled() { return (1 === (int)Class_CosmoVar::get('site_retrait_resa')); } + public function isSiteRetraitResaItemLibrary() { + return (0 === (int)Class_CosmoVar::get('site_retrait_resa')); + } + + public function isSiteRetraitResaPatronLibrary() { + return (2 === (int)Class_CosmoVar::get('site_retrait_resa')); + } + + public function getLabelInList($name, $value) { if (!$model = Class_CosmoVar::find($name)) diff --git a/library/Class/Users.php b/library/Class/Users.php index 36fea8215cafc5b86e2ccc94373c871a07e05f3c..45b58221d4eaff95e00a7125a0cc31189ff065c6 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -371,6 +371,12 @@ class Class_Users extends Storm_Model_Abstract { return $bib->getLibelle(); } + public function getUserIdSite() { + $comm = new Class_CommSigb(); + return $comm->getUserAnnexe($this); +// return $this->id_site; + } + /** * @return bool diff --git a/library/Class/WebService/SIGB/AbstractService.php b/library/Class/WebService/SIGB/AbstractService.php index 3a34374ea0f7eb0b9274326fc590dc307b6d4689..f1a85586b301ab4fddcbacdbd6afd283c6c13be5 100644 --- a/library/Class/WebService/SIGB/AbstractService.php +++ b/library/Class/WebService/SIGB/AbstractService.php @@ -62,6 +62,8 @@ abstract class Class_WebService_SIGB_AbstractService { abstract public function getEmprunteur($user); + abstract public function getUserAnnexe($user); + abstract public function reserverExemplaire($user, $exemplaire, $code_annexe); diff --git a/library/Class/WebService/SIGB/BiblixNet/Service.php b/library/Class/WebService/SIGB/BiblixNet/Service.php index 540cbe20c348890cec7428e6fe603980c0ebcfbe..d3177ea2946e85f96261ea66fa6842f7ffae9ecc 100644 --- a/library/Class/WebService/SIGB/BiblixNet/Service.php +++ b/library/Class/WebService/SIGB/BiblixNet/Service.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_Webservice_SIGB_BiblixNet_Service extends Class_WebService_SIGB_AbstractRESTService { @@ -49,6 +49,11 @@ class Class_Webservice_SIGB_BiblixNet_Service extends Class_WebService_SIGB_Abst } + public function getUserAnnexe($user) { + return null; + } + + /** * @param Class_Users $user * @param int $notice_id @@ -89,13 +94,13 @@ class Class_Webservice_SIGB_BiblixNet_Service extends Class_WebService_SIGB_Abst 'code'); } - + /** * @param string $id * @return Class_WebService_SIGB_Notice */ public function getNotice($id) { - return $this->ilsdiGetRecords($id, + return $this->ilsdiGetRecords($id, Class_WebService_SIGB_BiblixNet_GetRecordsResponseReader::newInstance()); } diff --git a/library/Class/WebService/SIGB/Carthame/Service.php b/library/Class/WebService/SIGB/Carthame/Service.php index 09e68594fbd5f9780b1ac25de6f6bf7d216ddd04..4114b98ca2323538fa6020d78bc16bfc133b4cce 100644 --- a/library/Class/WebService/SIGB/Carthame/Service.php +++ b/library/Class/WebService/SIGB/Carthame/Service.php @@ -118,6 +118,11 @@ class Class_WebService_SIGB_Carthame_Service extends Class_WebService_SIGB_Abstr } + public function getUserAnnexe($user) { + return null; + } + + /** * @param Class_Users $user * @param Class_Exemplaire exemplaire diff --git a/library/Class/WebService/SIGB/Dynix/Service.php b/library/Class/WebService/SIGB/Dynix/Service.php index 80bd597336393d4eacd4047ae5910c603820dd71..519b21a7b2bd6e8ed6a11b8079ed022c8c65e056 100644 --- a/library/Class/WebService/SIGB/Dynix/Service.php +++ b/library/Class/WebService/SIGB/Dynix/Service.php @@ -106,6 +106,11 @@ class Class_Webservice_SIGB_Dynix_Service extends Class_WebService_SIGB_Abstract } + public function getUserAnnexe($user) { + return null; + } + + public function reserverExemplaire($user, $exemplaire, $code_annexe){ if (!$sigb_exemplaire = $this->getExemplaire($exemplaire->getIdOrigine(), $exemplaire->getCodeBarres())) { diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php index 889ea7168795ecf555e89f2bead9a3529a83e5e8..ac93502a312a2580d774aadc0c46fd55a5beb92f 100644 --- a/library/Class/WebService/SIGB/Koha/Service.php +++ b/library/Class/WebService/SIGB/Koha/Service.php @@ -72,6 +72,11 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR } + public function getUserAnnexe($user) { + return null; + } + + public function holdItem($user,$exemplaire,$code_annexe) { $itemnumber=$exemplaire->getSubfield(9); $args = ['patron_id' => $this->_authenticate($user), diff --git a/library/Class/WebService/SIGB/Microbib/Service.php b/library/Class/WebService/SIGB/Microbib/Service.php index 6624fe6e2c23a45845a288fae1357bb0166f8e35..cb6bb672545d54cc6742e35c6eec6f4249fd06a3 100644 --- a/library/Class/WebService/SIGB/Microbib/Service.php +++ b/library/Class/WebService/SIGB/Microbib/Service.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_WebService_SIGB_Microbib_Service extends Class_WebService_SIGB_AbstractService { @@ -49,6 +49,11 @@ class Class_WebService_SIGB_Microbib_Service extends Class_WebService_SIGB_Abstr } + public function getUserAnnexe($user) { + return null; + } + + public function reserverExemplaire($user, $exemplaire, $code_annexe) { $xml = $this->_search_client->ajout_reservation($user->getLogin(), $exemplaire->getCodeBarres()); return $this->_actionResponseFromXML($xml); @@ -73,7 +78,7 @@ class Class_WebService_SIGB_Microbib_Service extends Class_WebService_SIGB_Abstr if ($response == 'Ok') return array('statut' => true, 'erreur' => ''); - return array('statut' => false, 'erreur' => array_last(explode('_', $response))); + return array('statut' => false, 'erreur' => array_last(explode('_', $response))); } } diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index 38cc85b1fc9f966f9d97750735ad17e7119d531c..becd0a9da1d271c3e4ffb1cab7d3179a6d93f6d4 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -48,6 +48,11 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac } + public function getUserAnnexe($user) { + return $user->id_site; + } + + public function saveEmprunteur($emprunteur) { $xml = $this->getWebClient() ->postData($this->buildQueryURL(['service'=>'UpdatePatronInfo', diff --git a/library/Class/WebService/SIGB/Opsys/Service.php b/library/Class/WebService/SIGB/Opsys/Service.php index b8fcf5358256ecd437b6a5c2f67b01f14b1d26d9..c60379361eef51d782bdffa33661afbb634e985a 100644 --- a/library/Class/WebService/SIGB/Opsys/Service.php +++ b/library/Class/WebService/SIGB/Opsys/Service.php @@ -217,6 +217,9 @@ class Class_WebService_SIGB_Opsys_Service extends Class_WebService_SIGB_Abstract return $this->authentifierEmprunteur($user); } + public function getUserAnnexe($user) { + return null; + } /** * @param Class_Users $user diff --git a/library/Class/WebService/SIGB/Orphee/Service.php b/library/Class/WebService/SIGB/Orphee/Service.php index bbbe5d2b92b2871230729ee317e93e050a16df82..eff4c98be848fe21d726da5c7488bbc9f1288cdd 100644 --- a/library/Class/WebService/SIGB/Orphee/Service.php +++ b/library/Class/WebService/SIGB/Orphee/Service.php @@ -135,6 +135,10 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac }); } + public function getUserAnnexe($user) { + return null; + } + protected function hasGetAdh() { return $this->_search_client->hasFunction('GetAdh'); diff --git a/library/Class/WebService/SIGB/Pergame/Service.php b/library/Class/WebService/SIGB/Pergame/Service.php index 40fadf007a975a19b0076983c912a8c4e6e47e7a..fc17cb5494df982fe8e0d94dce370f9b8481f554 100644 --- a/library/Class/WebService/SIGB/Pergame/Service.php +++ b/library/Class/WebService/SIGB/Pergame/Service.php @@ -63,6 +63,11 @@ class Class_WebService_SIGB_Pergame_Service extends Class_WebService_SIGB_Abstra } + public function getUserAnnexe($user) { + return null; + } + + public function getEmpruntsOf($emprunteur) { $params = Class_IntBib::find($this->_id_bib)->getCommParamsAsArray(); $renouvelable = isset($params['Autoriser_prolongations']) ? $params['Autoriser_prolongations'] : false; diff --git a/library/Class/WebService/SIGB/VSmart/Service.php b/library/Class/WebService/SIGB/VSmart/Service.php index c21f6d7e1b165c902986186db3e8d78ad9a46ede..1f716d503f900c290bb056eb3fceccd58eb50b51 100644 --- a/library/Class/WebService/SIGB/VSmart/Service.php +++ b/library/Class/WebService/SIGB/VSmart/Service.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_WebService_SIGB_VSmart_Service extends Class_WebService_SIGB_AbstractRESTService { @@ -136,6 +136,10 @@ class Class_WebService_SIGB_VSmart_Service extends Class_WebService_SIGB_Abstrac ->setPassword($user->getPassword()); } + public function getUserAnnexe($user) { + return null; + } + /** * @param string $id diff --git a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php index 1b94c2ed647cb6baa46dc50cac3372bed1bc3561..3d4d5c8210b2680cee917443869a92728f42811b 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php @@ -16,10 +16,10 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class RechercheControllerReservationPickupAjaxActionTest extends AbstractControllerTestCase { +class RechercheControllerReservationPickupAjaxActionTestWithChosenPickup extends AbstractControllerTestCase { protected $_json, $_xpath; public function setUp() { @@ -35,8 +35,10 @@ class RechercheControllerReservationPickupAjaxActionTest extends AbstractControl Class_CodifAnnexe::getLoader()->newInstanceWithId(3) ->setLibelle('Cran') ->setCode('CRN'))); - Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur'=>1]); - + + + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 1]); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=ANN',true); $this->_json = json_decode($this->_response->getBody()); $this->_xpath = new Storm_Test_XPath(); @@ -61,9 +63,165 @@ class RechercheControllerReservationPickupAjaxActionTest extends AbstractControl public function layoutShouldBeEmpty() { $this->_xpath->assertNotXPath($this->_json->content, '//div[@id="banniere"]'); } + +} + + +class RechercheControllerReservationPickupAjaxActionTestWithChosenPickupDispatch extends AbstractControllerTestCase { + protected $_json, $_xpath; + + public function setUp() { + parent::setUp(); + + $this->jajm = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'jajm', + 'password' => 'secret', + 'idabon' => '0000007', + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + $this->nanook = Storm_Test_ObjectWrapper::mock() + ->whenCalled('isConnected')->answers(true) + ->whenCalled('reserverExemplaire')->answers(true); + + + + + Class_WebService_SIGB_Nanook::setService($this->nanook); + + ZendAfi_Auth::getInstance()->logUser($this->jajm); + + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 1]); + + $this->dispatch('recherche/reservationajax/id/11760/id_int_bib/23/id_bib/23/id_origine/594105/code_annexe/23/render/popup',true); + $this->_json = json_decode($this->_response->getBody()); + $this->_xpath = new Storm_Test_XPath(); + } + + /** @test */ + public function parameterCodeAnnexeShouldBeUsedForReservation() { + $this->assertEquals('23', + $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); + + } + + } +class RechercheControllerReservationPickupAjaxActionTestWithPatronLibraryPickup extends AbstractControllerTestCase { + protected $_json, $_xpath; + + public function setUp() { + parent::setUp(); + + $this->jajm = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'jajm', + 'password' => 'secret', + 'idabon' => '0000007', + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 12, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + $this->nanook = Storm_Test_ObjectWrapper::mock() + ->whenCalled('isConnected')->answers(true) + ->whenCalled('reserverExemplaire')->answers(true) + ->whenCalled('getUserAnnexe')->answers('12'); + + Class_WebService_SIGB_Nanook::setService($this->nanook); + + ZendAfi_Auth::getInstance()->logUser($this->jajm); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') + ->whenCalled('findAllBy') + ->with(array('no_pickup' => '0', + 'order' => 'libelle')) + ->answers(array(Class_CodifAnnexe::getLoader()->newInstanceWithId(2) + ->setLibelle('Annecy') + ->setCode('ANN'), + Class_CodifAnnexe::getLoader()->newInstanceWithId(3) + ->setLibelle('Cran') + ->setCode('CRN'))); + + + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 2]); + + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=ANN',true); + $this->_json = json_decode($this->_response->getBody()); + $this->_xpath = new Storm_Test_XPath(); + } + + + /** @test */ + public function getUserAnnexeResultShouldBeUsedForReservation() { + $this->assertEquals('12', + $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); + + } +} + + + +class RechercheControllerReservationPickupAjaxActionTestWithItemLibraryPickup extends AbstractControllerTestCase { + protected $_json, $_xpath; + + public function setUp() { + parent::setUp(); + + $this->jajm = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'jajm', + 'password' => 'secret', + 'idabon' => '0000007', + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + $this->nanook = Storm_Test_ObjectWrapper::mock() + ->whenCalled('isConnected')->answers(true) + ->whenCalled('reserverExemplaire')->answers(true); + + + Class_WebService_SIGB_Nanook::setService($this->nanook); + + ZendAfi_Auth::getInstance()->logUser($this->jajm); + + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') + ->whenCalled('findAllBy') + ->with(array('no_pickup' => '0', + 'order' => 'libelle')) + ->answers(array(Class_CodifAnnexe::getLoader()->newInstanceWithId(2) + ->setLibelle('Annecy') + ->setCode('ANN'), + Class_CodifAnnexe::getLoader()->newInstanceWithId(3) + ->setLibelle('Cran') + ->setCode('CRN'))); + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 0]); + + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=ANN',true); + $this->_json = json_decode($this->_response->getBody()); + $this->_xpath = new Storm_Test_XPath(); + } + + /** @test */ + public function itemAnnexeShouldBeUsedForReservation() { + $this->assertEquals('ANN', + $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); + + } + + +} class RechercheControllerReservationWithMailPostAction extends AbstractControllerTestCase { @@ -107,21 +265,21 @@ class RechercheControllerReservationWithMailPostAction extends AbstractControlle /** @test */ public function firstMailFromShouldBeNanuk() { - $this->assertEquals('nanuk@gloub.com', + $this->assertEquals('nanuk@gloub.com', $this->first_mail->getFrom()); } /** @test */ public function firstMailSubjectShouldBeDemandeDeReservation() { - $this->assertContains('Demande de réservation de document', + $this->assertContains('Demande de réservation de document', quoted_printable_decode($this->first_mail->getSubject())); } /** @test */ public function firstMailToShouldBeZork() { - $this->assertContains('zork@gloub.fr', + $this->assertContains('zork@gloub.fr', $this->first_mail->getRecipients()); } @@ -141,14 +299,14 @@ class RechercheControllerReservationWithMailPostAction extends AbstractControlle /** @test */ public function secondMailFromShouldBeNobody() { - $this->assertEquals('nobody@noreply.fr', + $this->assertEquals('nobody@noreply.fr', $this->last_mail->getFrom()); } /** @test */ public function secondMailToShouldBeNanuk() { - $this->assertContains('nanuk@gloub.com', + $this->assertContains('nanuk@gloub.com', $this->last_mail->getRecipients()); } } @@ -158,13 +316,13 @@ class RechercheControllerReservationWithMailPostAction extends AbstractControlle class RechercheControllerReservationWithWebServiceKohaTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); - - $this->jajm = $this->fixture('Class_Users', + + $this->jajm = $this->fixture('Class_Users', ['id' => 1, 'login' => 'jajm', 'password' => 'secret', - 'int_bib' => $this->fixture('Class_IntBib', - ['id' => 1, + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 1, 'comm_sigb' => Class_IntBib::COM_KOHA, 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) ]); @@ -197,9 +355,9 @@ class RechercheControllerReservationWithWebServiceKohaTest extends AbstractContr /** @test */ public function withMatchingHoldAndRecordMessageShouldContainsPickupLocationAndRecordTitleAuthor() { - $exemplaire = $this->fixture('Class_Exemplaire', + $exemplaire = $this->fixture('Class_Exemplaire', ['id' => 456, - 'notice' => $this->fixture('Class_Notice', + 'notice' => $this->fixture('Class_Notice', ['id' => 8890, 'titre_principal' => 'Arcadia', 'auteur_principal' => 'Matsumoto'])]); @@ -212,7 +370,7 @@ class RechercheControllerReservationWithWebServiceKohaTest extends AbstractContr /** @test */ public function withoutMatchingHoldMessageShouldNotContainsPickupLocation() { $this->_dispatchWithEmprunteurAndAssertContentEquals( - $this->_prepareEmprunteurHolding(null, 'Valensole'), + $this->_prepareEmprunteurHolding(null, 'Valensole'), 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document sera disponible'); } @@ -243,7 +401,7 @@ class RechercheControllerReservationWithWebServiceKohaTest extends AbstractContr protected function _dispatchWithEmprunteurAndAssertContentEquals($emprunteur, $content) { $this->koha ->whenCalled('isConnected')->answers(true) - ->whenCalled('reserverExemplaire')->answers(['statut' => true, + ->whenCalled('reserverExemplaire')->answers(['statut' => true, 'erreur' => '', 'popup' => false]) ->whenCalled('getEmprunteur')->answers($emprunteur); diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php index dbe120805e5812bc3993e18c83f72e4af141c843..e0ecfa97e6fb1aab70e68340d1db4a7a0a6ba7e2 100644 --- a/tests/library/Class/WebService/SIGB/NanookTest.php +++ b/tests/library/Class/WebService/SIGB/NanookTest.php @@ -78,15 +78,11 @@ abstract class NanookTestCase extends Storm_Test_ModelTestCase { ->setServerRoot('http://localhost:8080/afi_Nanook/ilsdi/') ->setWebClient($this->_mock_web_client); - $annexe_cran = Class_CodifAnnexe::getLoader()->newInstanceWithId(3) - ->setLibelle('Annexe Cran-Gevrier') - ->setIdBib(3) - ->setCode(10); + $this->fixture('Class_CodifAnnexe' , ['id' => 3, + 'libelle' => 'Annexe Cran-Gevrier', + 'id_bib' => 3, + 'code' => 10]); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') - ->whenCalled('findFirstBy')->answers(null) - ->whenCalled('findFirstBy')->with(array('id_bib' => 3))->answers($annexe_cran) - ->whenCalled('findFirstBy')->with(array('code' => 10))->answers($annexe_cran); } } @@ -371,6 +367,26 @@ class NanookGetNoticeWithErrorTest extends NanookTestCase { } +class NanookGetUserAnnexeTest extends NanookTestCase { + public function setUp() { + parent::setUp(); + $this->_chrystel = Class_Users::newInstance(['id_sigb' => 1, + 'login' => 8765, + 'password' => 2002, + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 12, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]) + ]); + + } + + /** @test */ + public function getUserAnnexeShouldMatchUserGetIdSite() { + $this->assertEquals($this->_service->getUserAnnexe($this->_chrystel), $this->_chrystel->getUserIdSite()); + } + +} class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookTestCase {