Commit 24c7c89c authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#137459_probleme_affichage_des_prets_sur_mon_compte' into 'hotline'

hotline MT #137459 fix borower loans list when koha throwing error on history

See merge request afi/opacce!4128
parents 6bd0fc65 857cb47b
- ticket #137459 : Magasin de thèmes : correction de l'affichage des prêts en cours lorsque le SIGB Koha retourne une anomalie de l'historique de prêts.
\ No newline at end of file
......@@ -173,20 +173,26 @@ class Class_User_Cards extends Storm_Model_Collection {
public function getPNBLoans() {
$loans = $this->getLoans()
->select(function($loan)
{
return $loan->isPNB();
});
->select(function($loan)
{
return $loan->isPNB();
});
return $loans;
}
public function getLoansHistory() {
return $this->_decorateOperationFrom(
function($card) {
return $card->getLoansHistory();
});
/* see forge #137459 and koha library/Class/WebService/SIGB/Koha/RestfulService loanHistory($borrower) */
try {
return
$this->_decorateOperationFrom(function($card)
{
return $card->getLoansHistory();
});
} catch (Exception $exception) {
return new Storm_Collection;
}
}
......
......@@ -58,10 +58,11 @@ class Intonation_View_Abonne_AjaxLoans extends ZendAfi_View_Helper_BaseHelper {
'Loans' => $cards->getPNBLoans()]))
: '';
$history = $this->view->abonne_HistoryLoansList(new Class_Entity(['Profile' => Class_Profil::getCurrentProfil(),
'RequestParams' => [],
'User' => $this->_model,
'Loans' => $cards->getLoansHistory([])]));
$history =
$this->view->abonne_HistoryLoansList(new Class_Entity(['Profile' => Class_Profil::getCurrentProfil(),
'RequestParams' => [],
'User' => $this->_model,
'Loans' => $cards->getLoansHistory([])]));
$html = [];
......
......@@ -23,8 +23,8 @@
class Intonation_View_Abonne_HistoryLoansList extends Intonation_View_Abonne_LoansList {
public function abonne_HistoryLoansList($user) {
return parent::abonne_LoansList($user);
public function abonne_HistoryLoansList($config) {
return parent::abonne_LoansList($config);
}
protected function _renderList($collection, $actions) {
......
......@@ -21,16 +21,16 @@
class Intonation_View_Abonne_LoansList extends ZendAfi_View_Helper_BaseHelper {
protected $_config;
public function abonne_LoansList($config) {
$this->_config = $config;
if ($error = $config->getError())
return $error;
return $this->render($config->getLoans());
return ($error = $config->getError())
? $error
: $this->render($config->getLoans());
}
......
......@@ -1096,6 +1096,11 @@ class KohaFixtures {
public static function xmlGetPatronLaureIssuesHistoryError() {
return '';
}
public static function xmlLookupPatronJeanAndre() {
return '<?xml version="1.0" encoding="UTF-8" ?>
<LookupPatron>
......
......@@ -106,10 +106,10 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes
'id_notice' => 820]);
$exemplaire_troy = $this->fixture('Class_Exemplaire',
['id' => 12090,
'code_barres' => 123,
'id_int_bib' => 1,
'id_notice' => 820]);
['id' => 12090,
'code_barres' => 123,
'id_int_bib' => 1,
'id_notice' => 820]);
$this->fixture('Class_Notice',
['id' => 820,
......@@ -348,11 +348,11 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou
$reviews = Class_AvisNotice::groupByRecords(Class_AvisNotice::findAll());
$reviews = array_map(function($review)
{
return (new Intonation_Library_View_Wrapper_ReviewsByRecord)
->setModel($review)
->setView($this->view);
}, $reviews);
{
return (new Intonation_Library_View_Wrapper_ReviewsByRecord)
->setModel($review)
->setView($this->view);
}, $reviews);
$collection = new Storm_Collection($reviews);
......@@ -457,18 +457,18 @@ class TemplatesDispatchAbonneMonHistoriqueTest extends TemplatesIntonationAccoun
$notice_unimarc->newZone()->label('200')->addChild('a', 'Pottifar');
$notice = $this->fixture('Class_Notice',
['id' => 890,
'clef_alpha' => 'MYSUPERkey',
'unimarc' => $notice_unimarc->render(),
'facettes' => 'M8897 T1 B3 A18 Lfre']);
['id' => 890,
'clef_alpha' => 'MYSUPERkey',
'unimarc' => $notice_unimarc->render(),
'facettes' => 'M8897 T1 B3 A18 Lfre']);
$exemplaire = $this->fixture('Class_Exemplaire',
['id' => 891,
'id_origine' => 1234,
'code_barres' => 456,
'id_int_bib' => 1,
'zone995' => serialize([['clef' => 'a', 'valeur' => 'PottifarItem']]),
'notice' => $notice]);
['id' => 891,
'id_origine' => 1234,
'code_barres' => 456,
'id_int_bib' => 1,
'zone995' => serialize([['clef' => 'a', 'valeur' => 'PottifarItem']]),
'notice' => $notice]);
$pottifar_old_issue = new Class_WebService_SIGB_Emprunt('42', new Class_WebService_SIGB_Exemplaire(456));
$pottifar_old_issue
......@@ -516,18 +516,18 @@ class TemplatesDispatchAbonneLoansWithHistoryTest extends TemplatesIntonationAcc
$notice_unimarc->newZone()->label('200')->addChild('a', 'Pottifar');
$notice = $this->fixture('Class_Notice',
['id' => 890,
'clef_alpha' => 'MYSUPERkey',
'unimarc' => $notice_unimarc->render(),
'facettes' => 'M8897 T1 B3 A18 Lfre']);
['id' => 890,
'clef_alpha' => 'MYSUPERkey',
'unimarc' => $notice_unimarc->render(),
'facettes' => 'M8897 T1 B3 A18 Lfre']);
$exemplaire = $this->fixture('Class_Exemplaire',
['id' => 891,
'id_origine' => 1234,
'code_barres' => 456,
'id_int_bib' => 1,
'zone995' => serialize([['clef' => 'a', 'valeur' => 'PottifarItem']]),
'notice' => $notice]);
['id' => 891,
'id_origine' => 1234,
'code_barres' => 456,
'id_int_bib' => 1,
'zone995' => serialize([['clef' => 'a', 'valeur' => 'PottifarItem']]),
'notice' => $notice]);
$pottifar_old_issue = new Class_WebService_SIGB_Emprunt('42', new Class_WebService_SIGB_Exemplaire(456));
$pottifar_old_issue
......@@ -1339,7 +1339,6 @@ class TemplatesAbonneEditActionFicheTest extends Admin_AbstractControllerTestCas
class TemplatesAbonneAgendaDisabledTest extends AbstractControllerTestCase {
......@@ -1385,4 +1384,93 @@ class TemplatesAbonneJumbotronLoansTest extends TemplatesIntonationAccountTestCa
$this->dispatch('/abonne/has-loan/id_profil/72');
$this->assertXPath('//span[@class="success"]');
}
}
require_once __DIR__ . '/../../fixtures/KohaFixtures.php';
class TemplatesAbonneKohaAjaxLoansTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->_buildTemplateProfil(['id' => 5]);
$sigb_plage =
$this->fixture('Class_IntBib',
[
'id' => 3,
'comm_params' => ['url_serveur' => 'http://plage.com/cgi-bin/koha/ilsdi.pl',
'restful' => '1'],
'comm_sigb' => Class_IntBib::COM_KOHA
]);
$this->fixture('Class_Bib', ['id' => 3,
'libelle' => 'Bib de la plage 2',
'int_bib' => $sigb_plage]);
$user = $this->fixture('Class_Users',
['id' => 3,
'login' => 'thom',
'password' => 'thom',
'id_site' => 12,
'idabon' => '572',
'id_sigb' => '572',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'int_bib' => $sigb_plage]);
$logger = $this->mock()
->whenCalled('log')->answers(true)
->whenCalled('logError')
->willDo(
function($url, $message) {
throw new RuntimeException($url . ' :: ' . $message);
});
Class_WebService_SIGB_AbstractService::setLogger($logger);
Class_CommSigb::setLogger($logger);
ZendAfi_Auth::getInstance()->logUser($user);
$this->mock_web_client = $this->mock();
$sigb_comm = $sigb_plage->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/rest.pl/user/byid/572/issues_history')
->answers(KohaFixtures::xmlGetPatronLaureIssuesHistoryError())
->beStrict();
$this->dispatch('/opac/abonne/ajax-loans/id/3');
}
public function tearDown() {
Class_CommSigb::setLogger(null);
Class_WebService_SIGB_AbstractService::setLogger(null);
parent::tearDown();
}
/** @test */
public function shouldRenderEmptyBodyWithoutFatalError() {
$this->assertEmpty($this->_response->getBody());
}
}
\ No newline at end of file
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