diff --git a/VERSIONS_HOTLINE/129284 b/VERSIONS_HOTLINE/129284 new file mode 100644 index 0000000000000000000000000000000000000000..b843ee690853b7c5efb4a7b6f815d971821539f7 --- /dev/null +++ b/VERSIONS_HOTLINE/129284 @@ -0,0 +1 @@ + - ticket #129284 : Impossibilité d'ajouter des lecteurs sur des activités \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Koha/PatronInfoReader.php b/library/Class/WebService/SIGB/Koha/PatronInfoReader.php index 0f75c707c5a7f9105f388afe27980925b1b71e30..b4517b61192fc96b5283a4c4cca2997b072d7c89 100644 --- a/library/Class/WebService/SIGB/Koha/PatronInfoReader.php +++ b/library/Class/WebService/SIGB/Koha/PatronInfoReader.php @@ -21,7 +21,7 @@ class Class_WebService_SIGB_Koha_PatronInfoReader extends Class_WebService_SIGB_AbstractILSDIPatronInfoReader { - use Class_WebService_SIGB_Koha_TraitFormat, Trait_Translator; + use Class_WebService_SIGB_Koha_TraitFormat, Trait_Translator, Trait_TimeSource; protected $_current_exemplaire_operation, @@ -115,7 +115,12 @@ class Class_WebService_SIGB_Koha_PatronInfoReader public function endDebarred($data) { - if ($data) + if ($data === 1){ + $this->_emprunteur->beBlocked(); + return; + } + + if( strtotime($data) > $this->getCurrentTime()) $this->_emprunteur->beBlocked(); } diff --git a/tests/fixtures/KohaFixtures.php b/tests/fixtures/KohaFixtures.php index 8ee3e56e02379df1ba49793b9a044094875d5308..a273b9a8d6cbcafbef6b52abcddeb18b14bc32a2 100644 --- a/tests/fixtures/KohaFixtures.php +++ b/tests/fixtures/KohaFixtures.php @@ -1935,6 +1935,67 @@ class KohaFixtures { } + public static function xmlGetPatronInfoDebarredWithDate() { + return '<?xml version="1.0" encoding="UTF-8" ?> +<GetPatronInfo> + <privacy_guarantor_checkouts>0</privacy_guarantor_checkouts> + <updated_on>2019-02-18 09:26:19</updated_on> + <checkprevcheckout>inherit</checkprevcheckout> + <debarredcomment>OVERDUES_PROCESS 09/07/2017 23:41</debarredcomment> + <altcontactphone></altcontactphone> + <sex>F</sex> + <title>Mme.</title> + <country>FRANCE</country> + <altcontactsurname></altcontactsurname> + <sort1>EMPL</sort1> + <lang>default</lang> + <contactnote></contactnote> + <dateenrolled>2016-09-15</dateenrolled> + <categorycode>INDICALF</categorycode> + <B_address></B_address> + <altcontactzipcode></altcontactzipcode> + <B_email></B_email> + <email>badpatron@debarred.lol</email> + <altcontactfirstname></altcontactfirstname> + <othernames></othernames> + <borrowernotes></borrowernotes> + <mobile></mobile> + <zipcode>42600</zipcode> + <branchcode>MTRMTB</branchcode> + <fax></fax> + <surname>DEBARRED</surname> + <dateexpiry>2017-09-15</dateexpiry> + <address2></address2> + <phone></phone> + <B_phone></B_phone> + <B_country></B_country> + <privacy>1</privacy> + <loans> + </loans> + <altcontactaddress3></altcontactaddress3> + <city>Arkham</city> + <B_city></B_city> + <sort2></sort2> + <phonepro>123456790</phonepro> + <opacnote></opacnote> + <cardnumber>0000000</cardnumber> + <altcontactcountry></altcontactcountry> + <dateofbirth>1985-01-17</dateofbirth> + <debarred>2021-03-01</debarred> + <altcontactaddress1></altcontactaddress1> + <B_address2></B_address2> + <altcontactaddress2></altcontactaddress2> + <branchname>fictivBib</branchname> + <B_zipcode></B_zipcode> + <firstname>Bad Patron</firstname> + <address>rue de la zile</address> + <borrowernumber>420</borrowernumber> + <login_attempts>0</login_attempts> +</GetPatronInfo> +'; + } + + public static function xmlGetRecord2046() { return '<?xml version="1.0" encoding="UTF-8" ?> <GetRecords> diff --git a/tests/library/Class/WebService/SIGB/KohaTest.php b/tests/library/Class/WebService/SIGB/KohaTest.php index 02d9f95a5f9c30df49435326167ddb4bf17eb382..340ce24a739c50840a7c20b3b7bed09438007e83 100644 --- a/tests/library/Class/WebService/SIGB/KohaTest.php +++ b/tests/library/Class/WebService/SIGB/KohaTest.php @@ -877,6 +877,62 @@ class KohaGetEmprunteurDebarredWithIdSIGBTest extends KohaTestCase { +class KohaGetEmprunteurDebarredDateWithIdSIGBTest extends KohaTestCase { + + public function setUp() { + parent::setUp(); + $this->mock_web_client + ->whenCalled('postData') + ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl', + ['service' => 'AuthenticatePatron', + 'username' => 'JEAN', + 'password' => 'zork']) + ->answers(KohaFixtures::xmlLookupPatronDebarred()) + ->whenCalled('open_url') + ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=420&show_contact=1&show_loans=0&show_holds=1') + ->answers(KohaFixtures::xmlGetPatronInfoDebarredWithDate()); + + + } + + protected function _setTimeSourceAndgetEmprunteur($date){ + Class_WebService_SIGB_Koha_PatronInfoReader::setTimeSource(new TimeSourceForTest($date)); + + $this->jean = $this->service + ->getEmprunteur($this->fixture('Class_Users', + ['id' => 43, + 'login' => 'JEAN', + 'password' => 'zork', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'idabon' => 'Jean', + 'id_site' => 3, + 'id_sigb' => '420'])); + + } + + + public function tearDown() { + Class_WebService_SIGB_Koha_PatronInfoReader::setTimeSource(null); + } + + + /** @test */ + public function debarredWithDateInFutureShouldBeBlocked() { + $this->_setTimeSourceAndgetEmprunteur('2021-02-20'); + $this->assertTrue($this->jean->isBlocked()); + } + + + /** @test */ + public function debarredWithDateInPastShouldNotBeBlocked() { + $this->_setTimeSourceAndgetEmprunteur('2021-03-02'); + $this->assertFalse($this->jean->isBlocked()); + } +} + + + + class KohaGetEmprunteurJeanAndreWithIdSIGBTest extends KohaTestCase { public function setUp() { parent::setUp();