From 32683301fd48a3f8a0fb8fc82a4a14d3cef3512a Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Thu, 28 Nov 2013 15:51:07 +0000 Subject: [PATCH] =?UTF-8?q?Correction=20batchs=20r=C3=A9cup=C3=A9ration=20?= =?UTF-8?q?notices=20paniers=20lorsque=20lanc=C3=A9=20depuis=20Cosmogramme?= =?UTF-8?q?=20avec=20sauvegarde=20des=20idabon:=20erreur=20de=20session?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Class/Users.php | 6 +++++- tests/library/Class/UsersTest.php | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/library/Class/Users.php b/library/Class/Users.php index c5c5d366734..34215dd3447 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -85,8 +85,12 @@ class UsersLoader extends Storm_Model_Loader { * @return Class_Users */ public function getIdentity() { - if (!$user = ZendAfi_Auth::getInstance()->getIdentity()) + try { + if (!$user = ZendAfi_Auth::getInstance()->getIdentity()) + return null; + } catch(Zend_Session_Exception $e) { return null; + } return $this->find($user->ID_USER); } diff --git a/tests/library/Class/UsersTest.php b/tests/library/Class/UsersTest.php index c02c86782b9..84071775893 100644 --- a/tests/library/Class/UsersTest.php +++ b/tests/library/Class/UsersTest.php @@ -755,8 +755,26 @@ class UserStabiloUpdatedWithUserTomTest extends Storm_Test_ModelTestCase { public function stabiloShouldHaveOrdreabon1() { $this->assertEquals($this->stabilo->getOrdreabon(), '1'); } +} + + + +class UsersGetIdentityWithSessionErrorTest extends Storm_Test_ModelTestCase { + /** @test */ + public function getIdentityShouldReturnNullOnZendSessionException() { + ZendAfi_Auth::setInstance(Storm_Test_ObjectWrapper::mock() + ->whenCalled('getIdentity') + ->willDo( + function(){ + throw new Zend_Session_Exception('Session already started'); + } + ) + ); + $this->assertNull(Class_Users::getIdentity()); + } } + ?> \ No newline at end of file -- GitLab