Commit 28473e14 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'refs/remotes/origin/dev#77981_675_contractuelst_cloud_enregistrement_de_la_notion_de_cotisation_dans_fiche_lecteur_carte_bloquee' into origin-master

Conflicts:
	tests/db/UpgradeDBTest.php
	tests/fixtures/KohaFixtures.php
parents 81a5035c 83702ed5
Pipeline #6717 failed with stage
in 35 minutes and 13 seconds
- ticket #77981 : Abonnés SIGB : Ajout de la détection des cartes bloquées et des types d'abonnement
\ No newline at end of file
......@@ -24,6 +24,7 @@ class Class_WebService_SIGB_Emprunteur {
$_id,
$_name,
$_emprunts = [],
$_subscriptions = [],
$_reservations = [],
$_waiting_holds = [],
$_email = '',
......@@ -36,6 +37,7 @@ class Class_WebService_SIGB_Emprunteur {
$_nb_retards = null,
$_service = null,
$_valid = false,
$_blocked = false,
$_end_date = null,
$_ordre,
$_code_barres,
......@@ -74,7 +76,9 @@ class Class_WebService_SIGB_Emprunteur {
'_is_contact_email',
'_is_contact_sms',
'_library_code',
'_id_int_bib'];
'_id_int_bib',
'_subscriptions',
'_blocked'];
}
......@@ -288,6 +292,16 @@ class Class_WebService_SIGB_Emprunteur {
}
public function subscriptionAdd($subscription_id, $subscription_label) {
$this->_subscriptions[$subscription_id] = $subscription_label;
return $this;
}
public function getSubscriptions() {
return $this->_subscriptions;
}
/**
* @param array $emprunts
......@@ -717,6 +731,23 @@ class Class_WebService_SIGB_Emprunteur {
}
/**
* @return boolean
*/
public function beBlocked() {
$this->_blocked = true;
return $this;
}
/**
* @return boolean
*/
public function isBlocked() {
return $this->_blocked;
}
/**
* @param $user Class_Users
*/
......
......@@ -83,6 +83,17 @@ class Class_WebService_SIGB_Koha_PatronInfoReader extends Class_WebService_SIGB_
}
public function endCategorycode($data) {
$this->_emprunteur->subscriptionAdd($data,$data);
}
public function endDebarred($data) {
if ($data)
$this->_emprunteur->beBlocked();
}
public function endEmail($data) {
$this->getEmprunteur()->setEmail($data);
}
......
......@@ -28,7 +28,7 @@ class Class_WebService_SIGB_Orphee_GetInfoUserCarteResponseReader {
protected $_total_nb_reservations = 0;
protected $_subscription_id, $_subscription_label;
/**
* @return Class_WebService_SIGB_Orphee_GetInfoUserCarteResponseReader
......@@ -104,6 +104,22 @@ class Class_WebService_SIGB_Orphee_GetInfoUserCarteResponseReader {
}
public function endBloquee($data) {
if ($data)
$this->_emprunteur->beBlocked();
}
public function endCat_Pret($data) {
$this->_subscription_id = $data;
}
public function endLib_Cat_Pret($data) {
$this->_subscription_label = trim($data);
}
public function endNb_Prets($data) {
$this->_emprunteur->setNbEmprunts($data);
}
......@@ -132,6 +148,12 @@ class Class_WebService_SIGB_Orphee_GetInfoUserCarteResponseReader {
explode('/',
trim($data)))));
}
public function endUser() {
if (($this->_subscription_id !== null)
&& $this->_subscription_label)
$this->_emprunteur->subscriptionAdd($this->_subscription_id, $this->_subscription_label);
}
}
......
......@@ -67,6 +67,7 @@ abstract class UsersControllerWithMarcusTestCase extends AbstractControllerTestC
'adresse' => '34 avenue Funk',
'code_postal' => '99000',
'ville' => 'Jazz City',
'subscription_type' => '10;Jazzman',
'civilite' => Class_Users::CIVILITE_MONSIEUR]);
$this->marcus->setFicheSIGB(['type_comm' => 0])
......@@ -234,6 +235,16 @@ class UsersControllerIndexTest extends UsersControllerWithMarcusTestCase {
class UsersControllerEditMarcusTest extends UsersControllerWithMarcusTestCase {
public function setUp() {
parent::setUp();
$this->opsys_service = $this->mock();
$this->emprunteur = new Class_WebService_SIGB_Emprunteur('2341', 'Marcus');
$this->emprunteur->setService($this->opsys_service);
$this->emprunteur->subscriptionAdd('1','Zicos');
$this->emprunteur->beBlocked();
$this->marcus->setFicheSIGB(['type_comm' => Class_IntBib::COM_OPSYS,
'fiche' => $this->emprunteur]);
$this->dispatch('/admin/users/edit/id/10', true);
}
......
......@@ -739,7 +739,7 @@ class KohaFixtures {
<LookupPatron>
<id>572</id>
</LookupPatron>';
}
}
......@@ -885,13 +885,22 @@ class KohaFixtures {
public static function xmlLookupPatronJeanAndre() {
return '<?xml version="1.0" encoding="UTF-8" ?>
return '<?xml version="1.0" encoding="UTF-8" ?>
<LookupPatron>
<id>419</id>
</LookupPatron>';
}
public static function xmlLookupPatronDebarred() {
return '<?xml version="1.0" encoding="UTF-8" ?>
<LookupPatron>
<id>420</id>
</LookupPatron>';
}
public static function xmlLookupPatronLisianne() {
return '<?xml version="1.0" encoding="UTF-8" ?>
<LookupPatron>
......@@ -1226,11 +1235,12 @@ class KohaFixtures {
</issues>
</record>
</GetRecords>
';}
';
}
public static function xmlGetRecordsWithOnLoan () {
return
'<?xml version="1.0" encoding="ISO-8859-1" ?>
public static function xmlGetRecordsWithOnLoan () {
return
'<?xml version="1.0" encoding="ISO-8859-1" ?>
<GetRecords>
<record>
<biblioitemnumber>1</biblioitemnumber>
......@@ -1321,6 +1331,65 @@ class KohaFixtures {
</items>
</record>
</GetRecords>';
}
}
public static function xmlGetPatronInfoDebarred() {
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>9999-12-31</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>
';
}
}
?>
\ No newline at end of file
......@@ -456,6 +456,12 @@ class KohaGetEmprunteurLaureAfondTest extends KohaTestCase {
}
/** @test */
public function subscriptionShouldBeINDIVIDU() {
$this->assertEquals(['INDIVIDU' => 'INDIVIDU'], $this->laurent->getSubscriptions());
}
/** @test */
public function getIdShouldReturn572() {
$this->assertEquals(572, $this->laurent->getId());
......@@ -692,6 +698,44 @@ class KohaGetEmprunteurLisianneWithIdSIGBTest extends KohaTestCase {
}
class KohaGetEmprunteurDebarredWithIdSIGBTest 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=1&show_holds=1')
->answers(KohaFixtures::xmlGetPatronInfoDebarred());
$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']));
}
/** @test */
public function debarredShouldNotBeEmpty() {
$this->assertTrue($this->jean->isBlocked());
}
}
class KohaGetEmprunteurJeanAndreWithIdSIGBTest extends KohaTestCase {
public function setUp() {
parent::setUp();
......@@ -729,6 +773,13 @@ class KohaGetEmprunteurJeanAndreWithIdSIGBTest extends KohaTestCase {
}
/** @test */
public function jeanShouldNotBeBlocked() {
$this->assertFalse($this->jean->isBlocked());
}
/** @test */
public function prenomShouldBeJeanAndre() {
$this->assertEquals('Jean-André', $this->jean->getPrenom());
......
......@@ -908,6 +908,18 @@ class OrpheeServiceGetInfoUserCarteHenryDupontTest extends OrpheeServiceTestCase
}
/** @test */
public function emprunteurShouldNotBeBlocked() {
$this->assertFalse($this->emprunteur->isBlocked());
}
/** @test */
public function emprunteurShouldHaveLibCatPretContains() {
$this->assertEquals(['1' => 'Lecteur adulte'], $this->emprunteur->getSubscriptions());
}
/** @test */
public function nbOfHoldsWaitingToBePulledShouldBeOne() {
$this->assertCount(1, $this->emprunteur->getHoldsWaitingToBePulled());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment