Skip to content
Snippets Groups Projects
Commit cb12c677 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline 177809 fix borrower login when membership label has changed

parent c9c74fbb
Branches
Tags
1 merge request!4719hotline 177809 fix borrower login when membership label has changed
Pipeline #22793 passed with stage
in 23 minutes and 5 seconds
- correctif #177809 : Compte lecteur : Correction de la connexion à son compte lecteur.
\ No newline at end of file
......@@ -21,16 +21,13 @@
class MembershipLoader extends Storm_Model_Loader {
protected
$_used_memberships_cache;
public function findOrCreate(string $code,
string $libelle) : Class_Membership {
$params = ['code' => $code ?? 0];
if ($libelle)
$params['libelle'] = $libelle;
return Class_Membership::findFirstBy($params) ?? Class_Membership::newInstance($params);
public function findOrCreate(string $uniq_code,
string $label) : Class_Membership {
$params = ['code' => $uniq_code];
$membership = Class_Membership::findFirstBy($params) ?? Class_Membership::newInstance($params);
$membership->setLibelle($label);
return $membership;
}
......
......@@ -36,7 +36,7 @@ class Class_WebService_SIGB_Nanook_Emprunteur extends Class_WebService_SIGB_Empr
protected function _processSubscriptions(Class_Users $user) :void{
foreach ($this->getSubscriptions() as $subscription){
$membership = Class_Membership::findOrCreate( $subscription->getId(), $subscription->getLabel());
$membership = Class_Membership::findOrCreate($subscription->getId(), $subscription->getLabel());
if ($membership->isNew())
$membership->save();
$user_membership = Class_User_Membership::findOrCreate(
......
<?php
/**
* Copyright (c) 2012-2023, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class MembershipFindOrCreateTest extends ModelTestCase {
/** @test */
public function shouldReturnMembershipUniqInDB() {
$uniq_in_db =
$this->fixture(Class_Membership::class,
['id' => 1,
'code' => 'UNIQ IN DB',
'libelle' => 'ABC']);
$this->assertEquals($uniq_in_db, Class_Membership::findOrCreate('UNIQ IN DB', 'Nouveau libelle'));
return $uniq_in_db;
}
/**
* @test
* @depends shouldReturnMembershipUniqInDB
*/
public function uniqInDbLabelShouldBeNewLabel(Class_Membership $membership) {
$this->assertEquals('Nouveau libelle', $membership->getLibelle());
}
}
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