diff --git a/VERSIONS_HOTLINE/204325 b/VERSIONS_HOTLINE/204325 new file mode 100644 index 0000000000000000000000000000000000000000..5a435f61b4aff652d47096a725d99544e405f166 --- /dev/null +++ b/VERSIONS_HOTLINE/204325 @@ -0,0 +1 @@ + - correctif #204325 : Compte Abonné : Une dette payfip, liée à une régie sans identifiant, génére une erreur. \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Debt.php b/library/Class/WebService/SIGB/Debt.php index 7e103cfaf15671e4e228891b8c3f70e3782025b7..11113bf0ad20abec7005db922e5c65e20d76e40a 100644 --- a/library/Class/WebService/SIGB/Debt.php +++ b/library/Class/WebService/SIGB/Debt.php @@ -79,8 +79,9 @@ class Class_WebService_SIGB_Debt { public function getClientId(): string { - return $this->_client_id ?? - (new Class_AdminVar_Payfip)->clientId(); + if ($this->_client_id) + return $this->_client_id; + return (new Class_AdminVar_Payfip)->clientId(); } diff --git a/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php b/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php index 5b4d04639cb2f00be510b71ed9e3b51dd85b2b74..4d3922f2e4d47e7a01a14e0ab5c482546b25ecb5 100644 --- a/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php +++ b/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php @@ -125,15 +125,19 @@ class Class_WebService_SIGB_Nanook_PatronInfoReader } - public function endPaymentReceiverId(string $data): self { - if ( !($this->_xml_parser->inParents('debt') - && $this->_current_debt)) + public function endPaymentReceiverId(string $data): self + { + if ( ! ($this->_xml_parser->inParents('debt') + && $this->_current_debt)) return $this; - if ( $map = array_filter($this->_payment_receivers, - fn($receiver)=> ($receiver->id == trim($data)))) { - $this->_current_debt->setClientId(reset($map)->client_id); - $this->_current_debt->setClientLabel(reset($map)->label); + + if ($map = array_filter($this->_payment_receivers, + fn($receiver)=> ($receiver->id == trim($data)))) + { + $this->_current_debt->setClientId(reset($map)->client_id ?? ''); + $this->_current_debt->setClientLabel(reset($map)->label ?? ''); } + return $this; } diff --git a/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php b/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php index 2fcb687007441337cde0b2be34735993e30259f4..45e8b395128e63ba8c2c5c637ecbefb01ea06081 100644 --- a/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php +++ b/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php @@ -440,7 +440,7 @@ abstract class PayfipTemplatesAbonneDebtsDisplayTestCase extends PayfipTemplates -class PayfipTemplatesAbonneDebts2SitesDisplayTestCase extends PayfipTemplatesAbonneTestCase { +class PayfipTemplatesAbonneDebts2SitesDisplayTest extends PayfipTemplatesAbonneTestCase { protected $_nanook_client; public function setUp() { @@ -483,8 +483,49 @@ class PayfipTemplatesAbonneDebts2SitesDisplayTestCase extends PayfipTemplatesAbo public function contentTableFifthRowSecondColumnShouldContains_BadgeAmount_2() { $this->dispatch('/abonne/debts'); - $this->assertXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="9€00"]', $this->_response->getBody()); - $this->assertXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="8€00"]', $this->_response->getBody()); + $this->assertXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="9€00"]'); + $this->assertXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="8€00"]'); + } +} + + + + +class PayfipTemplatesAbonneDebtsWithoutClientIdTest extends PayfipTemplatesAbonneTestCase +{ + + protected PayfipMockNanookClient $_nanook_client; + + protected function activatePayfip() + { + $this->_buildTemplateProfil(['id' => 172]); + $cfg_accueil = ['modules' => [['division' => 4, + 'type_module' => 'LOGIN', + 'preferences' => []]]]; + + Class_Profil::getCurrentProfil() + ->setCfgAccueil($cfg_accueil) + ->assertSave(); + + Class_AdminVar::set(Class_AdminVar_Payfip::TEST_USERS, ''); + $this->enableMultiplePayfip(true); + $this->setPayfipOnAir('123000'); + $this->setPayfipOnAir('666'); + $user = $this->createUserForSite(336, 'hubert', $this->getBibAnnecy()); + $this->setupMockNanook($this->_nanook_client = new PayfipMockNanookClient); + $this->_nanook_client + ->onOpenUrl('/GetPatronInfo/patronId/336')->answerFile('patronInfoWithoutClientId.xml') + ->onOpenUrl('/AuthenticatePatron/')->answerFile('authenticatePatronSuccess.xml'); + + ZendAfi_Auth::getInstance()->logUser($user); + } + + + /** @test */ + public function debtsShouldBeDisplayedOnLoginWidget() + { + $this->dispatch('/index/index'); + $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="2 prestations à régler"]'); } } @@ -529,8 +570,8 @@ class PayfipTemplatesAbonneDebts2SitesOneAvailableDisplayTestCase extends Payfip public function contentTableFifthRowSecondColumnShouldContains_BadgeAmount_2() { $this->dispatch('/abonne/debts'); - $this->assertNotXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="9€00"]', $this->_response->getBody()); - $this->assertXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="8€00"]', $this->_response->getBody()); + $this->assertNotXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="9€00"]'); + $this->assertXPath('//span[contains(@class, "badge_tag")]/span[contains(@class, "badge_text")][text()="8€00"]'); } } @@ -1264,8 +1305,7 @@ class PayfipTemplatesAbonneDebtsDispatchWithValidDebtsAndPaymentInitiatedTest /** @test */ public function onlyOneDebtShouldBeDisplayed(){ $this->assertXPathCount('//form//input[@type="checkbox"][contains(@id, "debt_id_")]', - 1, - $this->_response->getBody()); + 1); } diff --git a/tests/scenarios/Payfip/patronInfoWithoutClientId.xml b/tests/scenarios/Payfip/patronInfoWithoutClientId.xml new file mode 100644 index 0000000000000000000000000000000000000000..a0588ec8971f3d096fbfa98bed1e810cadb2b19f --- /dev/null +++ b/tests/scenarios/Payfip/patronInfoWithoutClientId.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<GetPatronInfo> + <patronId>28434</patronId> + <siteId>20</siteId> + <barcode>336</barcode> + <cardType>Individuel</cardType> + <cardStatus>Carte active</cardStatus> + <notes> + </notes> + <newsletter>0</newsletter> + <alertPreviousLoanOnDocument>1</alertPreviousLoanOnDocument> + <noAnonymization>0</noAnonymization> + <loanForbidden>0</loanForbidden> + <holdForbidden>0</holdForbidden> + <parentalAuthorization>1</parentalAuthorization> + <multimediaAccess>0</multimediaAccess> + <lastName>TEST PAYFIP</lastName> + <firstName>Estelle</firstName> + <displayOrder>1</displayOrder> + <birthDate>2000-01-01</birthDate> + <phoneNumber> + </phoneNumber> + <mail> + </mail> + <endDate>2025-03-06</endDate> + <sendingChannels> + <sendingChannel> + <id>0</id> + <label>Indifférent</label> + <favorite>true</favorite> + </sendingChannel> + <sendingChannel> + <id>1</id> + <label>Courriel</label> + </sendingChannel> + <sendingChannel> + <id>2</id> + <label>SMS</label> + </sendingChannel> + <sendingChannel> + <id>3</id> + <label>Courrier</label> + </sendingChannel> + </sendingChannels> + <town> + </town> + <zipcode> + </zipcode> + <address> + </address> + <loans/> + <holds/> + <suggests/> + <subscriptions> + <subscription> + <rateId>1</rateId> + <rateLabel>Individuel</rateLabel> + <startDate>2024-03-06</startDate> + <endDate>2025-03-06</endDate> + </subscription> + </subscriptions> + <paymentsReceivers> + <paymentReceiver> + <id>2</id> + <label>Régie Mauléon</label> + </paymentReceiver> + <paymentReceiver> + <id>1</id> + <label>Régie Bressuire</label> + <payFipId>666</payFipId> + </paymentReceiver> + </paymentsReceivers> + <debts> + <debt> + <id>6237</id> + <label>Impression 100 crédits</label> + <amount>9.00</amount> + <paymentReceiverId>2</paymentReceiverId> + </debt> + <debt> + <id>6238</id> + <label>Lettre retard</label> + <amount>8.00</amount> + <paymentReceiverId>1</paymentReceiverId> + </debt> + <debt> + <id>6234</id> + <label>Abonnement</label> + <amount>25.00</amount> + <paymentReceiverId>2</paymentReceiverId> + <paymentId>20240306a142957Test</paymentId> + </debt> + </debts> +</GetPatronInfo>