diff --git a/VERSIONS_WIP/76799 b/VERSIONS_WIP/76799 new file mode 100644 index 0000000000000000000000000000000000000000..105e94ca47c037465feac56b3a540f66ac6baef8 --- /dev/null +++ b/VERSIONS_WIP/76799 @@ -0,0 +1 @@ + - ticket #76799 : Compte lecteur : correction de la mise à jour des cartes liées. \ No newline at end of file diff --git a/library/Class/User/Cards.php b/library/Class/User/Cards.php index ecb7257e20d6d323c9c69fb6790084093b9448f2..14dc5ce157cc138d0474a21869612fa9bc3cb1c8 100644 --- a/library/Class/User/Cards.php +++ b/library/Class/User/Cards.php @@ -54,6 +54,11 @@ class Class_User_Cards extends Storm_Model_Collection { } + public function updateFromPatron() { + return new Storm_Collection($card->updateFromPatron()); + } + + public function countWaitingToBePulled() { return $this->injectInto(0, function($count, $card) @@ -192,8 +197,7 @@ class Class_User_Cards extends Storm_Model_Collection { public function registerNotificationsOn($notifiable) { $this->eachDo(function($card) use ($notifiable) { - if (!$card->hasPagedLoans()) - (new Class_User_ILSSubscription($card))->registerNotificationsOn($notifiable); + (new Class_User_ILSSubscription($card))->registerNotificationsOn($notifiable); }); try { diff --git a/library/Class/User/ILSSubscription.php b/library/Class/User/ILSSubscription.php index 2564fc6b1177a53861cb7a2b4f0d57f12fd347eb..8a4811c48f597629bbfcbe4dc9cd23d808f6bccd 100644 --- a/library/Class/User/ILSSubscription.php +++ b/library/Class/User/ILSSubscription.php @@ -88,6 +88,11 @@ class Class_User_ILSSubscription { public function registerNotificationsOn($notifiable) { + $this->_user->updateFromPatron(); + + if ($this->_user->hasPagedLoans()) + return; + if(($user = Class_Users::getIdentity()) && $this->_user->getId() == $user->getId()) return $this->registerNotificationsForMeOn($notifiable); diff --git a/library/Class/Users.php b/library/Class/Users.php index 8f6a8558eb019059f35d12843e44484afbfe3c25..590f3fb1648006f513a9a081d107ae1bc848de0f 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -351,8 +351,10 @@ class UsersLoader extends Storm_Model_Loader { ->setLogin($login) ->setIdSite($library->getId()) ->setIdIntBib($library->getId()); + if (!Class_AdminVar::isLoginThroughSigbOnlyEnabled()) $user->setPassword(uniqid()); + $user->save(); return $user; @@ -1909,4 +1911,14 @@ class Class_Users extends Storm_Model_Abstract { public function isBlocked() { return $this->getEmprunteur()->isBlocked(); } + + + public function updateFromPatron() { + if (!$borrower = $this->getEmprunteur()) + return $this; + + $borrower->updateUser($this); + $this->save(); + return $this; + } } diff --git a/library/Class/WebService/SIGB/AbstractService.php b/library/Class/WebService/SIGB/AbstractService.php index 9f30e2550640197588d6a25b6b27a9ca48996895..72a6573606cbd682678c1b0503102a11e17977ae 100644 --- a/library/Class/WebService/SIGB/AbstractService.php +++ b/library/Class/WebService/SIGB/AbstractService.php @@ -55,6 +55,7 @@ abstract class Class_WebService_SIGB_AbstractService { public static function logError($url, $message) { if (!static::$_logger) return; + static::$_logger->logError($url, $message); } diff --git a/tests/scenarios/MultiCards/MultiCardsTest.php b/tests/scenarios/MultiCards/MultiCardsTest.php index 3ef384dd84c7bca0eefe86c74191acc15c5d85a7..a97bac7d78e0d6b08400280a8794f491ba9038d3 100644 --- a/tests/scenarios/MultiCards/MultiCardsTest.php +++ b/tests/scenarios/MultiCards/MultiCardsTest.php @@ -463,6 +463,8 @@ abstract class Scenario_AbonneMultiCardsAccountOfEwokTestCase extends Scenario_A ->setWaitingToBePulled(); $emprunteur = (new Class_WebService_SIGB_Emprunteur('2', 'luke')) + ->setPrenom('Luky') + ->setNom('Sky') ->empruntsAddAll([$potter, $alice]) ->reservationsAddAll([$arcadia]); @@ -596,7 +598,7 @@ class Scenario_AbonneMultiCardsAccountOfEwokNotificationsTest /** @test */ public function notificationShouldContainsOneCartWithValidityMessage() { - $this->assertContains('L\'abonnement de Luke Skywalker a expiré - Merci de contacter la médiathèque', + $this->assertContains('L\'abonnement de Luky Sky a expiré - Merci de contacter la médiathèque', $this->_notifications); } } @@ -932,7 +934,7 @@ class Scenario_AbonneMultiCardsAccountOfEwokSmartphoneAbonneActionTest /** @test */ public function potterLoanShouldIndicateLoanedByLukeSkywalker() { - $this->assertXPathContentContains('//li//p', 'Emprunté par Luke Skywalker'); + $this->assertXPathContentContains('//li//p', 'Emprunté par Luky Sky'); } @@ -950,7 +952,7 @@ class Scenario_AbonneMultiCardsAccountOfEwokSmartphoneAbonneActionTest /** @test */ public function validityEndShouldBeDisplayed() { - $this->assertXPathContentContains('//ul//li','L\'abonnement de Luke Skywalker a expiré - Merci de contacter la médiathèque'); + $this->assertXPathContentContains('//ul//li','L\'abonnement de Luky Sky a expiré - Merci de contacter la médiathèque'); } } diff --git a/tests/scenarios/Templates/PolygoneTemplateTest.php b/tests/scenarios/Templates/PolygoneTemplateTest.php index 12ede45998cb5164c243c75a3cde928c766ef85d..fbd89de9d751188f795df6f6e634e77d72aa7da6 100644 --- a/tests/scenarios/Templates/PolygoneTemplateTest.php +++ b/tests/scenarios/Templates/PolygoneTemplateTest.php @@ -213,7 +213,7 @@ class PolygoneTemplateSuggestTest extends PolygoneTemplateTestCase { } } - +require_once __DIR__ . '/../../fixtures/KohaFixtures.php'; class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase { @@ -245,24 +245,30 @@ class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase { 'libelle' => 'Istres', 'id_origine' => 'IST']); - $borrower = new Class_WebService_SIGB_Emprunteur('2341', 'test'); - $borrower->setLibraryCode('IST'); - $user = $this->fixture('Class_Users', ['id' => 3, - 'login' => 'test', - 'password' => 'test', + 'login' => 'thom', + 'password' => 'thom', + 'id_site' => 12, + 'idabon' => '572', + 'id_sigb' => '572', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'int_bib' => $sigb_plage]); + + $luke = $this->fixture('Class_Users', + ['id' => 23, + 'login' => 'luke', + 'password' => 'ilovelightsabers', + 'nom' => 'Skywalker', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'prenom' => 'Luke', 'id_site' => 12, - 'id_sigb' => 'azerty', - 'int_bib' => $sigb_plage, - 'fiche_sigb' => ['type_comm' => 0, - 'fiche' => $borrower]]); + 'idabon' => '419', + 'id_sigb' => '419', + 'int_bib' => $sigb_plage]); - ZendAfi_Auth::getInstance()->logUser($user); + $user->addChildCard($luke)->save(); - $this->mock_web_client = $this->mock(); - $sigb_comm = Class_IntBib::find(3)->getSIGBComm(); - $sigb_comm->setWebClient($this->mock_web_client); $logger = $this->mock() ->whenCalled('log')->answers(true) @@ -274,10 +280,43 @@ class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase { }); Class_WebService_SIGB_AbstractService::setLogger($logger); + Class_CommSigb::setLogger($logger); + + ZendAfi_Auth::getInstance()->logUser($user); + + $this->mock_web_client = $this->mock(); + + $sigb_comm = Class_IntBib::find(3)->getSIGBComm(); + $sigb_comm->setWebClient($this->mock_web_client); $this->mock_web_client + + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=572&show_contact=1&show_loans=0&show_holds=1') + ->answers(KohaFixtures::xmlGetPatronInfoLaure()) + + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=572&show_contact=0&show_loans=1&show_holds=0') + ->answers(KohaFixtures::xmlGetPatronInfoLaureLoans()) + + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=419&show_contact=1&show_loans=0&show_holds=1') + ->answers(KohaFixtures::xmlGetPatronInfoJeanAndre()) + + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=419&show_contact=0&show_loans=1&show_holds=0') + ->answers(KohaFixtures::xmlGetPatronInfoJeanAndreLoans()) + + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/koha/rest.pl/user/byid/419/issues_history') + ->answers(file_get_contents(realpath(dirname(__FILE__)) . '/../../fixtures/koha_issues_history_double.json')) + ->whenCalled('open_url') - ->with('http://plage.com/cgi-bin/koha/rest.pl/suggestions?branchcode=__ANY__&suggestedby=azerty') + ->with('http://plage.com/cgi-bin/koha/rest.pl/user/byid/572/issues_history') + ->answers(file_get_contents(realpath(dirname(__FILE__)) . '/../../fixtures/koha_issues_history_double.json')) + + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/koha/rest.pl/suggestions?branchcode=__ANY__&suggestedby=572') ->answers('[{ "date" : "2014-04-01 16:08:36", "STATUS" : "ASKED", @@ -296,7 +335,57 @@ class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase { "ASKED" : 1, "total" : "", "surnamemanagedby" : "", - "branchnamesuggestedby" : "Test", + "branchnamesuggestedby" : "Thom", + "price" : "", + "title" : "Trolls de troy", + "collectiontitle" : "", + "publicationyear" : "2012", + "itemtype" : "", + "place" : "", + "author" : "Laëtitia Gheno", + "suggesteddate" : "2013-11-14", + "currency" : "", + "borrnumsuggestedby" : "234", + "biblionumber" : "", + "categorycodesuggestedby" : "", + "manageddate" : "", + "acceptedby" : "", + "firstnamesuggestedby" : "", + "surnamesuggestedby" : "", + "publishercode" : "", + "suggestedby" : "azerty", + "rejecteddate" : null, + "firstnamemanagedby" : "", + "rejectedby" : null, + "quantity" : "0", + "note" : "Je veux le lire", + "patronreason" : "Je veux le lire", + "categorydescriptionsuggestedby" : "", + "volumedesc" : null, + "mailoverseeing" : "0", + "managedby" : ""}]') + + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/koha/rest.pl/suggestions?branchcode=__ANY__&suggestedby=419') + ->answers('[{ + "date" : "2014-04-01 16:08:36", + "STATUS" : "ASKED", + "suggestionid" : "6197", + "branchcodemanagedby" : "", + "accepteddate" : "", + "borrnummanagedby" : "", + "emailmanagedby" : "", + "branchcodesuggestedby" : "IST", + "isbn" : "9782814101425 ", + "emailsuggestedby" : "", + "branchcode" : "IST", + "copyrightdate" : "0", + "budgetid" : "", + "reason" : null, + "ASKED" : 1, + "total" : "", + "surnamemanagedby" : "", + "branchnamesuggestedby" : "luke", "price" : "", "title" : "En piste ! : Créations en couture pour petits et grands Enfant", "collectiontitle" : "", @@ -325,6 +414,7 @@ class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase { "volumedesc" : null, "mailoverseeing" : "0", "managedby" : ""}]') + ->beStrict(); $this->dispatch('/opac/abonne/suggestions'); @@ -332,6 +422,7 @@ class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase { public function tearDown() { + Class_CommSigb::setLogger(null); Class_WebService_SIGB_AbstractService::setLogger(null); Class_IntBib::find(3)->getSIGBComm()->setWebClient(null); parent::tearDown(); @@ -339,14 +430,36 @@ class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase { /** @test */ - public function suggestionEnPisteShouldBeDisplay() { - $this->assertXPathContentContains('//main//div', 'En piste ! : Créations en couture pour petits et grands Enfant'); + public function loginWidgetShouldBePresent() { + $this->assertXPath('//div[contains(@class, "login")][contains(@class, "widget")]'); + } + + + /** @test */ + public function suggestionTrollsDeTroyShouldBeDisplay() { + $this->assertXPathContentContains('//main//div', 'Trolls de troy suggéré par 572 thom'); } /** @test */ public function testShouldHaveWroteEnPisteSuggest() { - $this->assertXPathContentContains('//main//div', 'iste ! : Créations en couture pour petits et grands Enfant suggéré par test'); + $this->assertXPathContentContains('//main//div', 'En piste ! : Créations en couture pour petits et grands Enfant suggéré par 419 Luke Skywalker'); + } + + + /** @test */ + public function lukeDateFinShouldBe20100304() { + $user = Class_Users::find(23); + Class_WebService_SIGB_EmprunteurCache::newInstance()->remove($user); + $this->assertEquals('2010-03-04', $user->getDateFin()); + } + + + /** @test */ + public function thomDateFinShouldBe20120412() { + $user = Class_Users::find(3); + Class_WebService_SIGB_EmprunteurCache::newInstance()->remove($user); + $this->assertEquals('2012-04-12', $user->getDateFin()); } }