Commit a9a2204b authored by Ghislain Loas's avatar Ghislain Loas Committed by efalcy

dev #76799 fix updating child cards

parent d017705d
Pipeline #9635 passed with stage
in 43 minutes and 54 seconds
- ticket #76799 : Compte lecteur : correction de la mise à jour des cartes liées.
\ No newline at end of file
......@@ -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)
......@@ -181,8 +186,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 {
......
......@@ -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);
......
......@@ -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;
}
}
......@@ -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);
}
......
......@@ -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');
}
}
......
......@@ -207,7 +207,7 @@ class PolygoneTemplateSuggestTest extends PolygoneTemplateTestCase {
}
}
require_once __DIR__ . '/../../fixtures/KohaFixtures.php';
class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase {
......@@ -239,24 +239,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)
......@@ -268,10 +274,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",
......@@ -290,7 +329,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" : "",
......@@ -319,6 +408,7 @@ class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase {
"volumedesc" : null,
"mailoverseeing" : "0",
"managedby" : ""}]')
->beStrict();
$this->dispatch('/opac/abonne/suggestions');
......@@ -326,6 +416,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();
......@@ -333,14 +424,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());
}
}
......
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