Skip to content
Snippets Groups Projects
Commit 1877a2bc authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#66771_date_de_validite_de_la_carte_lecteur' into 'stable'

Hotline#66771 date de validite de la carte lecteur

See merge request !2447
parents d4b3fbec 6844af6a
Branches
Tags
2 merge requests!2464Master,!2447Hotline#66771 date de validite de la carte lecteur
Pipeline #3205 passed with stage
in 27 minutes and 59 seconds
- ticket #66771 : Compte Abonné : Correction de l'effacement de certaines informations de compte lors de l'identification par webservice
\ No newline at end of file
...@@ -219,27 +219,6 @@ class UsersLoader extends Storm_Model_Loader { ...@@ -219,27 +219,6 @@ class UsersLoader extends Storm_Model_Loader {
} }
public function mapUser($destination, $source) {
$destination
->setIdSigb($source->getIdSigb())
->setIdabon($source->getIdabon())
->setNom($source->getNom())
->setPrenom($source->getPrenom())
->setMail($source->getMail())
->setIsContactMail($source->getIsContactMail())
->setIsContactSms($source->getIsContactSms())
->setDateFin($source->getDateFin())
->setAdresse($source->getAdresse())
->setCodePostal($source->getCodePostal())
->setVille($source->getVille())
->setOrdreabon($source->getOrdreabon())
->setTelephone($source->getTelephone())
->setNaissance($source->getNaissance())
->setIdSite($source->getIdSite())
->setIdIntBib($source->getIdIntBib());
}
public function findBlowfish($login) { public function findBlowfish($login) {
$crypt = new Class_Crypt(); $crypt = new Class_Crypt();
return array_filter( return array_filter(
...@@ -1533,12 +1512,6 @@ class Class_Users extends Storm_Model_Abstract { ...@@ -1533,12 +1512,6 @@ class Class_Users extends Storm_Model_Abstract {
} }
public function updateUser($source) {
Class_Users::getLoader()->mapUser($this, $source);
return $this;
}
public function canModifyPanier($panier) { public function canModifyPanier($panier) {
if (!$panier || $panier->isNew()) if (!$panier || $panier->isNew())
return true; return true;
......
...@@ -61,17 +61,49 @@ class ZendAfi_Auth_Adapter_CommSigb implements Zend_Auth_Adapter_Interface { ...@@ -61,17 +61,49 @@ class ZendAfi_Auth_Adapter_CommSigb implements Zend_Auth_Adapter_Interface {
if(!$user_from_sigb) if(!$user_from_sigb)
return null; return null;
return $this->_getUserToSave($user_from_sigb) $user_to_save = $this->_getUserToSave($user_from_sigb)
->beAbonneSIGB() ->beAbonneSIGB()
->setLogin($this->_identity) ->setLogin($this->_identity)
->setPassword($this->_credential) ->setPassword($this->_credential);
->updateUser($user_from_sigb);
$this->_updateOptionalAttribs($user_from_sigb, $user_to_save);
return $user_to_save;
}
protected function _updateOptionalAttribs($from, $to) {
$attribs = ['id_sigb',
'idabon',
'nom',
'prenom',
'mail',
'is_contact_mail',
'is_contact_sms',
'date_fin',
'adresse',
'code_postal',
'ville',
'ordreabon',
'telephone',
'naissance',
'id_site',
'id_int_bib'];
foreach($attribs as $attrib)
$this->_updateAttribIfNotEmpty($from, $to, $attrib);
}
protected function _updateAttribIfNotEmpty($from, $to, $attrib) {
if ($value = $from->callGetterByAttributeName($attrib))
$to->callSetterByAttributeName($attrib, $value);
} }
protected function _getUserToSave($user_from_sigb) { protected function _getUserToSave($user_from_sigb) {
$finder = new Class_User_DoubleFinder($user_from_sigb); $finder = new Class_User_DoubleFinder($user_from_sigb);
return ($finder->find()) return $finder->find()
? $finder->getDouble() ? $finder->getDouble()
: Class_Users::newInstance()->setLogin($this->_identity); : Class_Users::newInstance()->setLogin($this->_identity);
} }
......
...@@ -850,37 +850,6 @@ class UsersFicheAbonneTest extends ModelTestCase { ...@@ -850,37 +850,6 @@ class UsersFicheAbonneTest extends ModelTestCase {
class UserStabiloUpdatedWithUserTomTest extends Storm_Test_ModelTestCase {
protected $stabilo, $tom;
public function setup() {
parent::setup();
$this->tom = Class_Users::newInstance(['login' => 'stabilo',
'naissance' => '15/08/1900',
'ordreabon' => '1']);
$this->stabilo = Class_Users::newInstance(['login' => 'stabilo'])->updateUser($this->tom);
}
/** @test **/
public function stabiloShouldHaveNaissance15Slash08Slash1900() {
$this->assertEquals($this->stabilo->getNaissance(), '15/08/1900');
}
/** @test **/
public function stabiloShouldHaveOrdreabon1() {
$this->assertEquals($this->stabilo->getOrdreabon(), '1');
}
}
class UsersGetIdentityWithSessionErrorTest extends Storm_Test_ModelTestCase { class UsersGetIdentityWithSessionErrorTest extends Storm_Test_ModelTestCase {
/** @test */ /** @test */
public function getIdentityShouldReturnNullOnZendSessionException() { public function getIdentityShouldReturnNullOnZendSessionException() {
......
...@@ -33,7 +33,17 @@ abstract class AuthCommSigbTestCase extends ModelTestCase { ...@@ -33,7 +33,17 @@ abstract class AuthCommSigbTestCase extends ModelTestCase {
'role_level' => 2, 'role_level' => 2,
'id_site' => 2, 'id_site' => 2,
'id_int_bib' => 2, 'id_int_bib' => 2,
'password' => 'xzy']); 'password' => 'xzy',
'id_sigb' => '7788',
'nom' => 'zork',
'prenom' => 'krog',
'mail' => 'zork.krog@zork.me',
'adresse' => '1 sesame street',
'code_postal' => '67883',
'ville' => 'Cloudy Cloud',
'ordreabon' => 3,
'telephone' => '0123456789',
'naissance' => '01-01-1934']);
$this->onLoaderOfModel('Class_Users'); $this->onLoaderOfModel('Class_Users');
} }
...@@ -484,4 +494,76 @@ class AuthCommSigbAuthenticationSetupInvalidUserTest ...@@ -484,4 +494,76 @@ class AuthCommSigbAuthenticationSetupInvalidUserTest
} }
} }
?>
\ No newline at end of file
/** @see http://forge.afi-sa.fr/issues/66771 */
class AuthCommSigbWithWebServicesAndAbonneZorkAndMinimalResponseTest
extends AuthCommSigbTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntBib',
['id' => 74,
'comm_sigb' => Class_IntBib::COM_OPSYS,
'nom_court' => 'TestingOpsys']);
$this->fixture('Class_IntMajAuto',
['id' => 100,
'id_bib' => 74,
'profil' => 57]);
$this->fixture('Class_IntProfilDonnees',
['id' => 57,
'libelle' => 'Some patrons',
'type_fichier' => Class_IntProfilDonnees::FT_PATRONS]);
Class_WebService_SIGB_Opsys::setService($this->opsys = $this->mock());
$annecy_library = $this->fixture('Class_Bib',
['id' => 43,
'libelle' => 'annecy']);
$annecy_annexe = $this->fixture('Class_CodifAnnexe',
['id' => 42,
'id_origine' => 'ANN',
'bib' => $annecy_library]);
$this->opsys
->whenCalled('getEmprunteur')
->answers(Class_WebService_SIGB_Emprunteur::newInstance('7788')
->setNom('Zork')
->setPrenom('Zinn')
->setPassword('xzy')
->setTelephone('')
->beValid());
$this->_zork->setIdIntBib(74)
->setIdSite(43)
->save();
$this->_adapter = (new ZendAfi_Auth_Adapter_CommSigb())
->setIdentity('zork_sigb')
->setCredential('xzy');
$this->_result = $this->_adapter->authenticate();
}
public function tearDown() {
Class_WebService_SIGB_Opsys::setService(null);
parent::tearDown();
}
/** @test */
public function dateFinShouldNotBeEmpty() {
$this->assertNotEmpty($this->_zork->getDateFin());
}
/** @test */
public function prenomShouldBecomeZinn() {
$this->assertEquals('Zinn', $this->_zork->getPrenom());
}
}
\ No newline at end of file
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