diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 6a7b0611b63fc898cac2350932cc48828f5a2303..a0e3fcb54a0d14dcb71b35ef4cf19ee7cd65536c 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -592,7 +592,7 @@ class RechercheController extends ZendAfi_Controller_Action { if ($response['erreur']) return $response['erreur']; - if ($response['popup']) + if (isset($response['popup']) && $response['popup']) return '<iframe src="' . $response['popup'] . '"></iframe>'; $current_hold = null; diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php index 384be9b64fd738e9bfd86437fe38035f009c0c47..c819f17ca9e15732e04920f75381145853a3b8c0 100644 --- a/library/Class/WebService/SIGB/Koha/Service.php +++ b/library/Class/WebService/SIGB/Koha/Service.php @@ -87,37 +87,31 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR } - public function holdItem($user,$exemplaire,$code_annexe) { - $itemnumber = $exemplaire->getSubfield(9); - $args = ['patron_id' => $user->getIdSigb(), - 'bib_id' => $exemplaire->getIdOrigine(), - 'item_id' => $itemnumber]; - - if (trim($code_annexe)) - $args['pickup_location'] = $code_annexe; - - return $this->ilsdiHoldItem($args, 'code'); + public function holdItem($user, $exemplaire, $code_annexe) { + return $this->ilsdiHoldItem($this->_setPickupLocation(['patron_id' => $user->getIdSigb(), + 'bib_id' => $exemplaire->getIdOrigine(), + 'item_id' => $exemplaire->getSubfield(9)], + $code_annexe), + 'code'); } - /** - * @param Class_Users $user - * @param Class_Exemplaire $exemplaire - * @param string $code_annexe - * @return array - */ public function reserverExemplaire($user, $exemplaire, $code_annexe) { if (1 == Class_AdminVar::get('KOHA_MULTI_SITES')) return $this->holdItem($user, $exemplaire, $code_annexe); - $args = ['patron_id' => $user->getIdSigb(), - 'bib_id' => $exemplaire->getIdOrigine(), - 'request_location' => '127.0.0.1']; + return $this->ilsdiHoldTitle($this->_setPickupLocation(['patron_id' => $user->getIdSigb(), + 'bib_id' => $exemplaire->getIdOrigine(), + 'request_location' => '127.0.0.1'], + $code_annexe), + 'code'); + } - if (trim($code_annexe)) - $args['pickup_location'] = $code_annexe; - return $this->ilsdiHoldTitle($args, 'code'); + protected function _setPickupLocation($args, $code) { + if (trim($code) && $annexe = Class_CodifAnnexe::findFirstBy(['code' => $code])) + $args['pickup_location'] = $annexe->getIdOrigine(); + return $args; } diff --git a/tests/fixtures/ChamberyKohaFixtures.php b/tests/fixtures/ChamberyKohaFixtures.php new file mode 100644 index 0000000000000000000000000000000000000000..cd25abd237e0b8f8796e3699148c525359effff7 --- /dev/null +++ b/tests/fixtures/ChamberyKohaFixtures.php @@ -0,0 +1,432 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * 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 + */ + +class ChamberyKohaFixtures { + + public static function branches() { + return '[ + { + "name" : "Lamotte", + "code" : "LAMOTTESVX" + }, + { + "name" : "BM Chambéry", + "code" : "CHY-GB" + }]'; + } + + + public static function authenticatePatronChambelle() { + return '<?xml version="1.0" encoding="UTF-8" ?> +<AuthenticatePatron> + <id>18</id> +</AuthenticatePatron>'; + } + + + public static function getPatronInfoChambelle() { + return '<?xml version="1.0" encoding="UTF-8" ?> +<GetPatronInfo> + <description>CHY - Adultes tarif réduit (5 €)</description> + <dateexpiry>2017-03-02</dateexpiry> + <title></title> + <firstname>Laurent</firstname> + <dateenrolled>2005-04-19</dateenrolled> + <reservefee>0.000000</reservefee> + <categorycode>CHYA13</categorycode> + <smsalertnumber>0618660422</smsalertnumber> + <branchcode>CHY-JR</branchcode> + <emailpro></emailpro> + <cardnumber>93658</cardnumber> + <amountoutstanding>0</amountoutstanding> + <category_type>A</category_type> + <enrolmentperiod>12</enrolmentperiod> + <branchname>Médiathèque Jean-Jacques Rousseau - Chambéry</branchname> + <phonepro></phonepro> + <loans> + <loan> + <publishercode>Eyrolles</publishercode> + <biblionumber>303473</biblionumber> + <lastreneweddate>2017-01-24 00:00:00</lastreneweddate> + <holdingbranch>CHY-JR</holdingbranch> + <auto_renew>0</auto_renew> + <itemcallnumber>643 CAU</itemcallnumber> + <totalrenewals>1</totalrenewals> + <booksellerid>110</booksellerid> + <timestamp>2017-01-24 12:25:29</timestamp> + <withdrawn>0</withdrawn> + <number>CHY-1345180</number> + <issue_id>57460</issue_id> + <cardnumber>93658</cardnumber> + <itemnumber>300938</itemnumber> + <publicationyear>2005</publicationyear> + <datelastseen>2016-12-22</datelastseen> + <itype>PRETNORMAL</itype> + <branchcode>CHY-JR</branchcode> + <datelastborrowed>2016-12-22</datelastborrowed> + <homebranch>CHY-JR</homebranch> + <title>Guide pratique de la rénovation de façades</title> + <frameworkcode></frameworkcode> + <firstname>Laurent</firstname> + <barcode>1457271</barcode> + <ccode>LIV</ccode> + <itemlost>0</itemlost> + <cn_sort>643_000000000000000_CAU</cn_sort> + <dateaccessioned>2007-02-23</dateaccessioned> + <onloan>2017-02-21</onloan> + <renewals>1</renewals> + <price>35.00</price> + <isbn>2-212-11624-1</isbn> + <notforloan>0</notforloan> + <location>101</location> + <date_due_sql>2017-02-21 23:59:00</date_due_sql> + <datecreated>2016-12-19</datecreated> + <date_due>2017-02-21 23:59</date_due> + <volume>pierre, béton, brique</volume> + <borrowernumber>18347</borrowernumber> + <biblioitemnumber>303473</biblioitemnumber> + <author>Alexandre Caussarieu | Thierry Gaumart</author> + <damaged>0</damaged> + <issues>1</issues> + <permanent_location>101</permanent_location> + <copynumber>A</copynumber> + <surname>Veleur</surname> + <issuedate>2016-12-22 17:56</issuedate> + <replacementpricedate>2016-12-19</replacementpricedate> + <onsite_checkout>0</onsite_checkout> + </loan> + <loan> + <itype>PRETNORMAL</itype> + <datelastborrowed>2016-12-22</datelastborrowed> + <branchcode>CHY-JR</branchcode> + <number>CHY-2015765</number> + <withdrawn>0</withdrawn> + <issue_id>57462</issue_id> + <itemnumber>324055</itemnumber> + <cardnumber>93658</cardnumber> + <publicationyear>2013</publicationyear> + <datelastseen>2016-12-22</datelastseen> + <cn_sort>643_000000000000000_BEL</cn_sort> + <ccode>LIV</ccode> + <barcode>1573492</barcode> + <itemlost>0</itemlost> + <dateaccessioned>2013-03-14</dateaccessioned> + <homebranch>CHY-JR</homebranch> + <frameworkcode></frameworkcode> + <firstname>Laurent</firstname> + <title>Autoconstruire en bois</title> + <holdingbranch>CHY-JR</holdingbranch> + <auto_renew>0</auto_renew> + <itemcallnumber>643 BEL</itemcallnumber> + <notes>Adresses utiles</notes> + <publishercode>Eyrolles</publishercode> + <lastreneweddate>2017-01-24 00:00:00</lastreneweddate> + <biblionumber>324549</biblionumber> + <timestamp>2017-01-24 12:25:29</timestamp> + <totalrenewals>1</totalrenewals> + <booksellerid>3</booksellerid> + <replacementpricedate>2016-12-19</replacementpricedate> + <surname>Veleur</surname> + <copynumber>A</copynumber> + <issuedate>2016-12-22 17:56</issuedate> + <onsite_checkout>0</onsite_checkout> + <isbn>978-2-212-13290-8</isbn> + <notforloan>0</notforloan> + <location>101</location> + <datecreated>2016-12-19</datecreated> + <date_due_sql>2017-02-21 23:59:00</date_due_sql> + <onloan>2017-02-21</onloan> + <renewals>1</renewals> + <price>18.00</price> + <damaged>0</damaged> + <issues>1</issues> + <permanent_location>101</permanent_location> + <date_due>2017-02-21 23:59</date_due> + <volume>ossature bois, chevrons porteurs, poteaux-poutres, paille, bois cordé</volume> + <borrowernumber>18347</borrowernumber> + <author>Pierre-Gilles Bellin | Antoine Mazurier</author> + <biblioitemnumber>324549</biblioitemnumber> + </loan> + <loan> + <homebranch>CHY-JR</homebranch> + <title>Charpente, mode d\'emploi (La)</title> + <firstname>Laurent</firstname> + <frameworkcode></frameworkcode> + <itemlost>0</itemlost> + <barcode>1513590</barcode> + <ccode>LIV</ccode> + <cn_sort>646_000000000000000_VAL</cn_sort> + <dateaccessioned>2009-11-13</dateaccessioned> + <withdrawn>0</withdrawn> + <number>CHY-1758670</number> + <issue_id>57464</issue_id> + <cardnumber>93658</cardnumber> + <itemnumber>52088</itemnumber> + <datelastseen>2016-12-22</datelastseen> + <publicationyear>2009</publicationyear> + <itype>PRETNORMAL</itype> + <branchcode>CHY-JR</branchcode> + <datelastborrowed>2016-12-22</datelastborrowed> + <totalrenewals>1</totalrenewals> + <booksellerid>110</booksellerid> + <timestamp>2017-01-24 12:25:29</timestamp> + <publishercode>Eyrolles</publishercode> + <notes>Glossaire. BIbliogr.</notes> + <biblionumber>46159</biblionumber> + <lastreneweddate>2017-01-24 00:00:00</lastreneweddate> + <holdingbranch>CHY-JR</holdingbranch> + <auto_renew>0</auto_renew> + <itemcallnumber>646 VAL</itemcallnumber> + <onsite_checkout>0</onsite_checkout> + <copynumber>A</copynumber> + <surname>Veleur</surname> + <issuedate>2016-12-22 17:56</issuedate> + <replacementpricedate>2016-12-19</replacementpricedate> + <date_due>2017-02-21 23:59</date_due> + <borrowernumber>18347</borrowernumber> + <author>Jean-Louis Valentin</author> + <biblioitemnumber>46159</biblioitemnumber> + <damaged>0</damaged> + <permanent_location>101</permanent_location> + <issues>1</issues> + <onloan>2017-02-21</onloan> + <renewals>1</renewals> + <price>16.00</price> + <isbn>978-2-212-12329-6</isbn> + <notforloan>0</notforloan> + <location>101</location> + <date_due_sql>2017-02-21 23:59:00</date_due_sql> + <datecreated>2016-12-19</datecreated> + </loan> + <loan> + <biblionumber>277522</biblionumber> + <publishercode>P.O.L</publishercode> + <auto_renew>0</auto_renew> + <itemcallnumber>R DARR</itemcallnumber> + <holdingbranch>CHY-JR</holdingbranch> + <booksellerid>3</booksellerid> + <timestamp>2017-01-31 13:30:55</timestamp> + <datelastseen>2017-01-31</datelastseen> + <publicationyear>2016</publicationyear> + <withdrawn>0</withdrawn> + <number>CHY-2277239</number> + <issue_id>125223</issue_id> + <itemnumber>269551</itemnumber> + <cardnumber>93658</cardnumber> + <branchcode>CHY-JR</branchcode> + <datelastborrowed>2017-01-31</datelastborrowed> + <itype>PRETNORMAL</itype> + <title>Etre ici est une splendeur</title> + <firstname>Laurent</firstname> + <frameworkcode></frameworkcode> + <homebranch>CHY-JR</homebranch> + <dateaccessioned>2016-03-23</dateaccessioned> + <itemlost>0</itemlost> + <barcode>1613062</barcode> + <ccode>LIV</ccode> + <cn_sort>R_DARR</cn_sort> + <onloan>2017-02-28</onloan> + <location>1010</location> + <date_due_sql>2017-02-28 23:59:00</date_due_sql> + <datecreated>2016-12-19</datecreated> + <isbn>978-2-8180-3906-9</isbn> + <notforloan>0</notforloan> + <author>Marie Darrieussecq</author> + <biblioitemnumber>277522</biblioitemnumber> + <date_due>2017-02-28 23:59</date_due> + <volume>vie de Paula M. Becker</volume> + <borrowernumber>18347</borrowernumber> + <damaged>0</damaged> + <issues>2</issues> + <permanent_location>1010</permanent_location> + <issuedate>2017-01-31 13:30</issuedate> + <copynumber>A</copynumber> + <surname>Veleur</surname> + <replacementpricedate>2016-12-19</replacementpricedate> + <onsite_checkout>0</onsite_checkout> + </loan> + <loan> + <onloan>2017-02-28</onloan> + <notforloan>0</notforloan> + <date_due_sql>2017-02-28 23:59:00</date_due_sql> + <datecreated>2016-12-19</datecreated> + <location>201</location> + <borrowernumber>18347</borrowernumber> + <date_due>2017-02-28 23:59</date_due> + <author>écrit et réalisé par Mario Martone</author> + <biblioitemnumber>315839</biblioitemnumber> + <issues>3</issues> + <permanent_location>201</permanent_location> + <damaged>0</damaged> + <copynumber>D</copynumber> + <surname>Veleur</surname> + <issuedate>2017-01-31 13:30</issuedate> + <replacementpricedate>2016-12-19</replacementpricedate> + <onsite_checkout>0</onsite_checkout> + <materials>2 DVD Vid┬eo</materials> + <notes>2014. Version originale en italien. Sous-titres en français</notes> + <publishercode>Blaq out</publishercode> + <biblionumber>315839</biblionumber> + <holdingbranch>CHY-JR</holdingbranch> + <itemcallnumber>F LEO VO ITA P/C</itemcallnumber> + <auto_renew>0</auto_renew> + <booksellerid>11</booksellerid> + <timestamp>2017-01-31 13:30:59</timestamp> + <issue_id>125224</issue_id> + <itemnumber>314324</itemnumber> + <cardnumber>93658</cardnumber> + <withdrawn>0</withdrawn> + <number>CHY-2319446</number> + <publicationyear>2016</publicationyear> + <datelastseen>2017-01-31</datelastseen> + <itype>PRETNORMAL</itype> + <datelastborrowed>2017-01-31</datelastborrowed> + <branchcode>CHY-JR</branchcode> + <homebranch>CHY-JR</homebranch> + <title>Leopardi : Il giovane favoloso</title> + <frameworkcode></frameworkcode> + <firstname>Laurent</firstname> + <ccode>DVD</ccode> + <barcode>1617869</barcode> + <itemlost>0</itemlost> + <cn_sort>F_LEO_VO_ITA_P_C</cn_sort> + <dateaccessioned>2016-11-16</dateaccessioned> + </loan> + <loan> + <holdingbranch>CHY-JR</holdingbranch> + <auto_renew>0</auto_renew> + <itemcallnumber>700 VERM</itemcallnumber> + <publishercode>Evergreen</publishercode> + <biblionumber>303622</biblionumber> + <timestamp>2017-01-31 13:31:03</timestamp> + <totalrenewals>1</totalrenewals> + <booksellerid>1</booksellerid> + <itype>PRETNORMAL</itype> + <branchcode>CHY-JR</branchcode> + <datelastborrowed>2017-01-31</datelastborrowed> + <number>CHY-2305296</number> + <withdrawn>0</withdrawn> + <itemnumber>301117</itemnumber> + <issue_id>125225</issue_id> + <cardnumber>93658</cardnumber> + <publicationyear>2016</publicationyear> + <datelastseen>2017-01-31</datelastseen> + <cn_sort>700_000000000000000_VERM</cn_sort> + <barcode>1614628</barcode> + <ccode>LIV</ccode> + <itemlost>0</itemlost> + <dateaccessioned>2016-08-02</dateaccessioned> + <homebranch>CHY-JR</homebranch> + <firstname>Laurent</firstname> + <frameworkcode></frameworkcode> + <title>Johannes Vermeer</title> + <isbn>978-3-8365-0488-1</isbn> + <notforloan>0</notforloan> + <location>201</location> + <datecreated>2016-12-19</datecreated> + <date_due_sql>2017-02-28 23:59:00</date_due_sql> + <onloan>2017-02-28</onloan> + <damaged>0</damaged> + <issues>1</issues> + <permanent_location>201</permanent_location> + <volume>1632-1675 | ou les sentiments dissimulés</volume> + <date_due>2017-02-28 23:59</date_due> + <borrowernumber>18347</borrowernumber> + <author>Norbert Schneider</author> + <biblioitemnumber>303622</biblioitemnumber> + <replacementpricedate>2016-12-19</replacementpricedate> + <surname>Veleur</surname> + <copynumber>J</copynumber> + <issuedate>2017-01-31 13:31</issuedate> + <onsite_checkout>0</onsite_checkout> + </loan> + <loan> + <biblionumber>283317</biblionumber> + <publishercode>Snoeck Publishers | Bibliothèque municipale de Dijon</publishercode> + <notes>Bibliogr.</notes> + <auto_renew>0</auto_renew> + <itemcallnumber>940.3 MAN</itemcallnumber> + <holdingbranch>CHY-JR</holdingbranch> + <booksellerid>1</booksellerid> + <timestamp>2017-01-31 13:31:08</timestamp> + <publicationyear>2015</publicationyear> + <datelastseen>2017-01-31</datelastseen> + <withdrawn>0</withdrawn> + <number>CHY-2282759</number> + <itemnumber>276583</itemnumber> + <issue_id>125226</issue_id> + <cardnumber>93658</cardnumber> + <datelastborrowed>2017-01-31</datelastborrowed> + <branchcode>CHY-GB</branchcode> + <itype>PRETNORMAL</itype> + <title>Manger et boire.</title> + <frameworkcode></frameworkcode> + <firstname>Laurent</firstname> + <homebranch>CHY-JR</homebranch> + <dateaccessioned>2016-04-13</dateaccessioned> + <barcode>1601187</barcode> + <ccode>LIV</ccode> + <itemlost>0</itemlost> + <cn_sort>940_300000000000000_MAN</cn_sort> + <price>32.00</price> + <onloan>2017-02-28</onloan> + <location>2033</location> + <date_due_sql>2017-02-28 23:59:00</date_due_sql> + <datecreated>2016-12-19</datecreated> + <isbn>978-94-6161-278-6</isbn> + <notforloan>0</notforloan> + <author>sous la dir. de Caroline Poulain</author> + <biblioitemnumber>283317</biblioitemnumber> + <date_due>2017-02-28 23:59</date_due> + <volume>entre 1914 & 1918</volume> + <borrowernumber>18347</borrowernumber> + <damaged>0</damaged> + <permanent_location>2033</permanent_location> + <issues>2</issues> + <issuedate>2017-01-31 13:31</issuedate> + <copynumber>A</copynumber> + <surname>Veleur</surname> + <replacementpricedate>2016-12-19</replacementpricedate> + <onsite_checkout>0</onsite_checkout> + </loan> + </loans> + <othernames></othernames> + <address>chemin du poète</address> + <sex>M</sex> + <dateofbirth>1959-12-03</dateofbirth> + <phone>06 47 89 02 02</phone> + <is_expired>0</is_expired> + <streetnumber>213</streetnumber> + <mobile></mobile> + <email>boulandet@wanadoo.fr</email> + <zipcode>73110</zipcode> + <surname>Veleur</surname> + <city>LA CHAPELLE BLANCHE</city> + <BlockExpiredPatronOpacActions>1</BlockExpiredPatronOpacActions> + <country></country> + <borrowernumber>18347</borrowernumber> + <holds> + </holds> + <address2></address2> + <privacy>1</privacy> +</GetPatronInfo>'; + } +} \ No newline at end of file diff --git a/tests/scenarios/HandleBranchcode/HandleBranchcodeTest.php b/tests/scenarios/HandleBranchcode/HandleBranchcodeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c72b5c7adcbe7126a3d5a9e763793d072217c0ca --- /dev/null +++ b/tests/scenarios/HandleBranchcode/HandleBranchcodeTest.php @@ -0,0 +1,129 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * 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 + */ + +require_once 'tests/fixtures/ChamberyKohaFixtures.php'; + +abstract class HandleBranchcodeTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true, + $mock_web_client, + $service, + $user, + $ilsdi; + + public function setUp() { + parent::setUp(); + Class_WebService_SIGB_Koha::reset(); + Class_AdminVar::newInstanceWithId('KOHA_MULTI_SITES', ['valeur' => '' ]); + $this->ilsdi = 'http://chamb.com/koha/ilsdi.pl'; + $this->mock_web_client = $this->mock(); + $this->service = Class_WebService_SIGB_Koha::getService(['url_serveur' => $this->ilsdi, + 'id_bib' => 3, + 'type' => Class_IntBib::COM_KOHA]); + $this->service->setWebClient($this->mock_web_client); + + $this->mock_web_client + ->whenCalled('open_url') + ->with($this->ilsdi . '?service=AuthenticatePatron&username=Chambelle&password=upw') + ->answers(ChamberyKohaFixtures::authenticatePatronChambelle()) + + ->whenCalled('open_url') + ->with($this->ilsdi . '?service=GetPatronInfo&patron_id=18&show_contact=1&show_loans=1&show_holds=1') + ->answers(ChamberyKohaFixtures::getPatronInfoChambelle()); + + $this->fixture('Class_CodifAnnexe', + ['id' => 58, + 'libelle' => 'Bibliothèque Georges Brassens', + 'id_origine' => 'CHY-GB']); + + $sigb_gb = $this->fixture('Class_IntBib', + [ + 'id' => 3, + 'comm_params' => ['url_serveur' => $this->ilsdi], + 'comm_sigb' => Class_IntBib::COM_KOHA + ]); + + $this->fixture('Class_Bib', ['id' => 12, + 'libelle' => 'Bibliothèque Georges Brassens', + 'int_bib' => $sigb_gb]); + + $this->user = $this->fixture('Class_Users', + ['id' => 78, + 'login' => 'Chambelle', + 'password' => 'upw', + 'idabon' => '93658', + 'id_site' => 12, + 'int_bib' => $sigb_gb]); + + ZendAfi_Auth::getInstance()->logUser($this->user); + } +} + + + + +class HandleBranchcodeBorrowerTest extends HandleBranchcodeTestCase { + /** @test */ + public function borrowerLibraryLabelShouldBeGeorgesBrassens() { + $this->borrower = $this->service->getEmprunteur($this->user); + $this->assertEquals('Bibliothèque Georges Brassens', $this->borrower->getLibraryLabel()); + } +} + + + + +class HandleBranchcodeSuggestionTest extends HandleBranchcodeTestCase { + protected $expected_call = false; + + public function setUp() { + parent::setUp(); + + $this->mock_web_client + ->whenCalled('open_url') + ->with($this->ilsdi . '?service=HoldTitle&request_location=127.0.0.1&pickup_location=CHY-GB') + ->willDo(function() {$this->expected_call = true;}) + + ->whenCalled('open_url') + ->with($this->ilsdi . '?service=HoldItem&item_id=&pickup_location=CHY-GB') + ->willDo(function() {$this->expected_call = true;}); + + + $this->fixture('Class_Exemplaire', + ['id' => 16]); + } + + + /** @test */ + public function ilsdiHoldTitleShouldBeCallWithCHYMinusGB() { + $this->dispatch('/opac/recherche/reservation-pickup-ajax/id_notice/15/id_int_bib/1/id_bib/1/copy_id/16/code_annexe/CHYGB', true); + $this->assertTrue($this->expected_call); + } + + + /** @test */ + public function kohaMultiSitesIlsdiHoldTitleShouldBeCallWithCHYMinusGB() { + Class_AdminVar::newInstanceWithId('KOHA_MULTI_SITES', ['valeur' => 1]); + $this->dispatch('/opac/recherche/reservation-pickup-ajax/id_notice/15/id_int_bib/1/id_bib/1/copy_id/16/code_annexe/CHYGB', true); + $this->assertTrue($this->expected_call); + } + +} +?> \ No newline at end of file