diff --git a/VERSIONS_HOTLINE/177809 b/VERSIONS_HOTLINE/177809 new file mode 100644 index 0000000000000000000000000000000000000000..af13e5d60a699f1b7763b45b606f2bd319672dc9 --- /dev/null +++ b/VERSIONS_HOTLINE/177809 @@ -0,0 +1 @@ + - correctif #177809 : Compte lecteur : Correction de la connexion à son compte lecteur. \ No newline at end of file diff --git a/library/Class/Membership.php b/library/Class/Membership.php index f4c435f84b5d3cc7e53c43b5abcf5a60bd050181..04487f58e442961ca23a0ccda7725f732c6430ac 100644 --- a/library/Class/Membership.php +++ b/library/Class/Membership.php @@ -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; } diff --git a/library/Class/WebService/SIGB/Nanook/Emprunteur.php b/library/Class/WebService/SIGB/Nanook/Emprunteur.php index e7beb4e270f08c6f1c2fcf76b30440a26d5d0426..afe88f0fcbeabea1478835edb1901c28007f4aff 100644 --- a/library/Class/WebService/SIGB/Nanook/Emprunteur.php +++ b/library/Class/WebService/SIGB/Nanook/Emprunteur.php @@ -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( diff --git a/tests/library/Class/MembershipTest.php b/tests/library/Class/MembershipTest.php new file mode 100644 index 0000000000000000000000000000000000000000..54a2d1db177d097ca83e743ad02277dc2478bf06 --- /dev/null +++ b/tests/library/Class/MembershipTest.php @@ -0,0 +1,44 @@ +<?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()); + } +}