diff --git a/VERSIONS_WIP/178960 b/VERSIONS_WIP/178960
new file mode 100644
index 0000000000000000000000000000000000000000..fec4292ae608705d50adbab0bf55531cdac96f0d
--- /dev/null
+++ b/VERSIONS_WIP/178960
@@ -0,0 +1 @@
+ - fonctionnalité #178960 : Fixer la reconnaissance de la bibliothèque d'intégration pour les usagers qui se connectent pour la première fois au portail
\ No newline at end of file
diff --git a/cosmogramme/php/fonctions/objets_saisie.php b/cosmogramme/php/fonctions/objets_saisie.php
index ced288bbb117ea324ea63e344709cceac657be4f..7f79fe94651c01dbffbe52e0ed7055971fd9ee12 100644
--- a/cosmogramme/php/fonctions/objets_saisie.php
+++ b/cosmogramme/php/fonctions/objets_saisie.php
@@ -119,6 +119,9 @@ function getBlocsParams($id_bib, $type, $valeurs) {
     if (in_array($clef, [Class_IntBib::COM_ORPHEE]))
       $champs_params[0] = ['url_serveur',
                            'key',
+                           ['identification_server_provider' =>
+                            fn( $id, $value) => return getOuiNon($id, $value);
+                           ],
                            'allow_hold_available_items',
                            ['hold_mode' => function($id, $valeur) {
                                return getComboSimple($id,
@@ -226,4 +229,4 @@ function getBlocsParams($id_bib, $type, $valeurs) {
   }
   return $bloc;
 }
-?>
\ No newline at end of file
+?>
diff --git a/cosmogramme/sql/patch/patch_552.php b/cosmogramme/sql/patch/patch_552.php
new file mode 100644
index 0000000000000000000000000000000000000000..6000336384bf76b7efe81868e5b99ad94245ee38
--- /dev/null
+++ b/cosmogramme/sql/patch/patch_552.php
@@ -0,0 +1,2 @@
+<?php
+(new Class_Migration_CommSigbOrphee())->run();
diff --git a/library/Class/IntBib.php b/library/Class/IntBib.php
index f8f613c126abccec54a9fbf983cdd151fa01812c..844d5b75f98c1eaf89d4794a91ce2b85985ccbb0 100644
--- a/library/Class/IntBib.php
+++ b/library/Class/IntBib.php
@@ -519,6 +519,12 @@ class Class_IntBib extends Storm_Model_Abstract {
   }
 
 
+  public function isOrphee() {
+    return (static::SIGB_ORPHEE == $this->getSigb())
+      || (static::COM_ORPHEE == $this->getCommSigb());
+  }
+
+
   public function isCommNanook() {
     return Class_IntBib::COM_NANOOK == $this->getCommSigb();
   }
diff --git a/library/Class/Migration/CommSigbOrphee.php b/library/Class/Migration/CommSigbOrphee.php
new file mode 100644
index 0000000000000000000000000000000000000000..a2060e6ddd469026c6ac0c37b831171f9d1ec41b
--- /dev/null
+++ b/library/Class/Migration/CommSigbOrphee.php
@@ -0,0 +1,37 @@
+<?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 Class_Migration_CommSigbOrphee {
+
+  public function run() :self{
+    $all_comm_orphee = Class_IntBib::findAllBy(['comm_sigb'=> Class_IntBib::COM_ORPHEE]);
+    if (count($all_comm_orphee)>20)
+      return $this;
+    foreach($all_comm_orphee as $library) {
+      $params = $library->getCommParamsAsArray();
+      if(isset($params['identification_server_provider']))
+        continue;
+      $params['identification_server_provider']=true;
+      $library->setCommParams($params);
+      $library->save();
+    }
+    return $this;
+  }
+}
diff --git a/library/Class/User/DoubleFinder.php b/library/Class/User/DoubleFinder.php
index 1ad904707fa55d6d081b7a3730a4f38406b892ad..582bdf3afa9f574d5cf022a887dcd8ab7b9723e1 100644
--- a/library/Class/User/DoubleFinder.php
+++ b/library/Class/User/DoubleFinder.php
@@ -22,9 +22,16 @@
 
 class Class_User_DoubleFinder extends Class_Entity {
   public function __construct($patron) {
-    $this->setStrategy((Class_IntBib::isSingleNanookPatrons())
-                       ? new Class_User_DoubleFinder_NanookStrategy($patron)
-                       : new Class_User_DoubleFinder_DefaultStrategy($patron));
+    $this->setStrategy($this->_getStrategy($patron));
+  }
+
+
+  protected function _getStrategy($patron) : Class_User_DoubleFinder_DefaultStrategy {
+    if (Class_IntBib::isSingleNanookPatrons())
+      return new Class_User_DoubleFinder_NanookStrategy($patron);
+    if ($patron->getIntBib() && $patron->getIntBib()->isOrphee())
+      return new Class_User_DoubleFinder_UniqueIdStrategy($patron);
+    return new Class_User_DoubleFinder_DefaultStrategy($patron);
   }
 
 
@@ -164,4 +171,13 @@ class Class_User_DoubleFinder_NanookStrategy
   protected function _restrictToIntegration($params) {
     return $params;
   }
-}
\ No newline at end of file
+}
+
+
+
+
+class Class_User_DoubleFinder_UniqueIdStrategy extends Class_User_DoubleFinder_DefaultStrategy {
+  protected function _restrictToIntegration($params) {
+    return $params;
+  }
+}
diff --git a/library/Class/WebService/SIGB/AbstractService.php b/library/Class/WebService/SIGB/AbstractService.php
index 21ac15497a6fd148ddb31a4828c2bab6386bece3..306254c070e7ae0f5e191bb4189d35b89316e2c7 100644
--- a/library/Class/WebService/SIGB/AbstractService.php
+++ b/library/Class/WebService/SIGB/AbstractService.php
@@ -31,7 +31,7 @@ abstract class Class_WebService_SIGB_AbstractService {
 
   protected static $_logger;
   protected $_notice_cache;
-
+  protected bool $_identification_provider = false;
 
   /**
    * @return Class_WebService_SIGB_AbstractService
@@ -240,6 +240,18 @@ abstract class Class_WebService_SIGB_AbstractService {
   }
 
 
+  public function setDefaultLibraryToEmprunteur($emprunteur, int $library_id) : self{
+    $emprunteur->setIdIntBib($library_id);
+    return $this;
+  }
+
+
+  public function beIdentificationProvider() : self {
+    $this->_identification_provider = true;
+    return $this;
+  }
+
+
   abstract public function getServerRoot();
 
   abstract public function getEmprunteur($user);
diff --git a/library/Class/WebService/SIGB/Emprunteur.php b/library/Class/WebService/SIGB/Emprunteur.php
index ee8cd89062d506f938d2180d7abb0ccb7855a1e1..9ea83e66e30d38bedad1d3801f27e7bc59ba5d28 100644
--- a/library/Class/WebService/SIGB/Emprunteur.php
+++ b/library/Class/WebService/SIGB/Emprunteur.php
@@ -270,6 +270,13 @@ class Class_WebService_SIGB_Emprunteur {
   }
 
 
+  public function getIntBib() {
+    return $this->getIdIntBib()
+      ? Class_IntBib::find($this->getIdIntBib())
+      : null;
+  }
+
+
   /**
    * @return string
    */
diff --git a/library/Class/WebService/SIGB/LibraryWrapper.php b/library/Class/WebService/SIGB/LibraryWrapper.php
index 97d6dc1f03e6cc0cefffb46cd1eda2d8d1617381..a60827428d6bd548a0d1996b6f60627e7befd521 100644
--- a/library/Class/WebService/SIGB/LibraryWrapper.php
+++ b/library/Class/WebService/SIGB/LibraryWrapper.php
@@ -34,9 +34,9 @@ class Class_WebService_SIGB_LibraryWrapper {
   }
 
 
-  public function getEmprunteur($user) {
+  public function getEmprunteur($user){
     if ($emprunteur = $this->_service->getEmprunteur($user))
-      $emprunteur->setIdIntBib($this->_library->getId());
+      $this->_service->setDefaultLibraryToEmprunteur( $emprunteur, $this->_library->getId());
 
     return $emprunteur;
   }
diff --git a/library/Class/WebService/SIGB/Orphee.php b/library/Class/WebService/SIGB/Orphee.php
index 3d0e44e912162699d7bfeb188454e217263627a3..7f4408e8e25b24346adb7b9e7f22e512f463c569 100644
--- a/library/Class/WebService/SIGB/Orphee.php
+++ b/library/Class/WebService/SIGB/Orphee.php
@@ -36,15 +36,23 @@ class Class_WebService_SIGB_Orphee {
                                                                 $params['key'] ?? null,
                                                                 $params['allow_hold_available_items'] ?? null);
 
+    return static::$_services[$key] = static::_updateParams($service, $params);
+  }
+
+
+  protected static function _updateParams(Class_WebService_SIGB_Orphee_Service $service,array $params) : Class_WebService_SIGB_Orphee_Service {
     if (isset($params['hold_mode']) && (Class_WebService_SIGB_Orphee_Service::HOLD_MODE_ITEM === (int)$params['hold_mode']))
       $service->beHoldModeItem();
 
-    return static::$_services[$key] = $service;
+    if (isset($params['identification_server_provider']))
+      $service->beIdentificationProvider();
+    return $service;
   }
 
 
   public static function setService(array $params, Class_WebService_SIGB_Orphee_Service $service) : void {
-    static::$_services[static::makeKey($params)] = $service;
+
+    static::$_services[static::makeKey($params)] = static::_updateParams($service, $params);
   }
 
 
diff --git a/library/Class/WebService/SIGB/Orphee/GetInfoUserCarteResponseReader.php b/library/Class/WebService/SIGB/Orphee/GetInfoUserCarteResponseReader.php
index cb305c60fe4d4528e575ec6a44f04768cb973af8..c1906a24fb231691b06f8fc1432d372bf5c44b4d 100644
--- a/library/Class/WebService/SIGB/Orphee/GetInfoUserCarteResponseReader.php
+++ b/library/Class/WebService/SIGB/Orphee/GetInfoUserCarteResponseReader.php
@@ -159,6 +159,10 @@ class Class_WebService_SIGB_Orphee_GetInfoUserCarteResponseReader {
 
   public function endAnx(string $data) : void {
     $this->_emprunteur->setLibraryCode(trim($data));
+
+    if (!$annexe = Class_CodifAnnexe::findByCode(trim($data)))
+      return;
+    $this->_emprunteur->setIdIntBib($annexe->getIdBib());
   }
 }
 
diff --git a/library/Class/WebService/SIGB/Orphee/Service.php b/library/Class/WebService/SIGB/Orphee/Service.php
index c55b1436cb8e3dcd0ded4fbafdb9aa88562eeafe..9a9c8de213a8916df66ac54dab3ca6d0446345ca 100644
--- a/library/Class/WebService/SIGB/Orphee/Service.php
+++ b/library/Class/WebService/SIGB/Orphee/Service.php
@@ -31,7 +31,8 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac
     $_key,
     $_allow_hold_available_items,
     $_soap_options,
-    $_hold_mode;
+    $_hold_mode
+;
 
 
   public static function getService($wsdl, $key=null, $allow_hold_available_items=null) {
@@ -171,7 +172,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac
 
 
   public function providesAuthentication() {
-    return $this->hasGetAdh() && Class_AdminVar::isLoginThroughSigbOnlyEnabled();
+    return $this->_identification_provider && $this->hasGetAdh() && Class_AdminVar::isLoginThroughSigbOnlyEnabled();
   }
 
 
@@ -198,6 +199,13 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac
   }
 
 
+  public function setDefaultLibraryToEmprunteur($emprunteur, int $library_id) : self{
+    if (!$emprunteur->getIdIntBib())
+      $emprunteur->setIdIntBib($library_id);
+    return $this;
+  }
+
+
   public function getUserAnnexe($user) {
     return null;
   }
diff --git a/library/ZendAfi/Auth/Adapter/CommSigb.php b/library/ZendAfi/Auth/Adapter/CommSigb.php
index 7c477ffbf2735da77d05faf4db639b8b8ce740b9..032b1624d23639c46f9e3c53f2a656627e367668 100644
--- a/library/ZendAfi/Auth/Adapter/CommSigb.php
+++ b/library/ZendAfi/Auth/Adapter/CommSigb.php
@@ -25,7 +25,6 @@ class ZendAfi_Auth_Adapter_CommSigb extends ZendAfi_Auth_Adapter_Abstract {
     $_called_services,
     $_loaner;
 
-
   public function __construct() {
     $this->_called_services = new Storm_Collection;
   }
@@ -58,18 +57,18 @@ class ZendAfi_Auth_Adapter_CommSigb extends ZendAfi_Auth_Adapter_Abstract {
   protected function _allCalledServicesHaveResponded() {
     return null === $this->_called_services
       ->detect(function($service)
-               {
-                 return $service->hasNetworkError();
-               });
+      {
+        return $service->hasNetworkError();
+      });
   }
 
 
   protected function _allCalledServicesProvideAuthentication() {
     return null === $this->_called_services
       ->detect(function($service)
-               {
-                 return !$service->providesAuthentication();
-               });
+      {
+        return !$service->providesAuthentication();
+      });
   }
 
 
@@ -115,13 +114,14 @@ class ZendAfi_Auth_Adapter_CommSigb extends ZendAfi_Auth_Adapter_Abstract {
   }
 
 
-  protected function _updateAttribIfNotEmpty(Class_Users $from, Class_USers $to, string $attrib) : void {
+  protected function _updateAttribIfNotEmpty(Class_Users $from, Class_Users $to, string $attrib) : self {
     $new_value = $from->callGetterByAttributeName($attrib);
 
     if ( null === $new_value || '' === $new_value)
-      return;
+      return $this;
 
     $to->callSetterByAttributeName($attrib, $new_value);
+    return $this;
   }
 
 
@@ -134,32 +134,48 @@ class ZendAfi_Auth_Adapter_CommSigb extends ZendAfi_Auth_Adapter_Abstract {
 
 
   protected function _getUserFromSigb($user) {
-    $bibs = $this->_getBibsToAuthenticateTo($user);
+    $bibs=[];
+    $libraries_from_user = false;
+    if ($user_in_db =  $this->_getUser($user))
+      $libraries_from_user = true;
+
+    $bibs= $this->_getBibsToAuthenticateTo( $user_in_db);
 
     foreach($bibs as $bib)
-      if ($user_found = $this->_getUserFromSigbWithLibrary($user, $bib))
+      if ($user_found = $this->_getUserFromSigbWithLibrary($user, $bib, $libraries_from_user))
         return $user_found;
 
     return null;
   }
 
 
-  protected function _getUserFromSigbWithLibrary($user, $library) {
+  protected function _getBibsToAuthenticateTo(?Class_Users $user_in_db) : array {
+    if (!$user_in_db)
+      return Class_IntBib::findAllWithWebServices();
+    if (!$user_in_db->isAbonne()
+        || (!$library = $user_in_db->getIntBib()) || (! $library->getSIGBComm()))
+      return [];
+    return[$library];
+  }
+
+
+  protected function _getUserFromSigbWithLibrary(Class_Users $user,Class_IntBib $library,bool $libraries_from_user) : ?Class_Users{
     $service = $library->getSIGBComm();
 
+    if ($libraries_from_user)
+      $service->beIdentificationProvider();
     if (!$service->providesAuthentication())
-      return;
+      return null;
 
     if (!$loaner = $service->getEmprunteur($user))
-      return;
-
+      return null;
     $this->_called_services->append($service);
 
     if (!$loaner->isValid())
-      return;
+      return null;
 
     if( !$loaner = $this->_loaner = $this->_loanerWithValidPassword($user, $loaner))
-      return;
+      return null;
 
     $loaner->updateUser($user);
 
@@ -186,18 +202,13 @@ class ZendAfi_Auth_Adapter_CommSigb extends ZendAfi_Auth_Adapter_Abstract {
   }
 
 
-  protected function _getBibsToAuthenticateTo($user) {
+  protected function _getUser(Class_Users $user) : ?Class_Users {
     $users_in_db = Class_Users::findAllBy(['login' => $user->getLogin()]);
-
     if (1 !== count($users_in_db))
-      return Class_IntBib::findAllWithWebServices();
-
-    $user_in_db = $users_in_db[0];
-    if (!$user_in_db->isAbonne()
-        || (!$bib = $user_in_db->getIntBib()) || (!$bib->getSIGBComm()))
-      return [];
+      return null;
 
-    return [$bib];
+    $user_in_db = reset($users_in_db);
+    return $user_in_db;
   }
 
 
diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php
index ae3d68cfa3d15f610c386127af541931aaf5a0ba..5c2f6d372c4b60561c2a89d2f4eb65be6f293beb 100644
--- a/tests/application/modules/opac/controllers/AuthControllerTest.php
+++ b/tests/application/modules/opac/controllers/AuthControllerTest.php
@@ -20,7 +20,10 @@
  */
 
 require_once 'tests/fixtures/KohaFixtures.php';
+require_once 'tests/library/Class/WebService/SIGB/OrpheeFixtures.php';
 require_once 'tests/fixtures/NewsletterFixtures.php';
+include_once('Class/WebService/SIGB/Orphee/Service.php');
+include_once('Class/WebService/SIGB/Orphee/SessionStrategy.php');
 
 abstract class PortailWithOneLoginModuleTestCase extends AbstractControllerTestCase {
   protected $_storm_default_to_volatile = true;
@@ -52,31 +55,34 @@ abstract class PortailWithOneLoginModuleTestCase extends AbstractControllerTestC
       ->setBrowser('opac')
       ->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil));
   }
-
 }
 
 
 
+
 class AuthControllerInviteLoggedTest extends PortailWithOneLoginModuleTestCase {
   protected function _loginHook($account) {
     $account->ROLE = "invite";
     $account->ROLE_LEVEL = 1;
   }
 
+
   public function setUp() {
     parent::setUp();
     $this->dispatch('/opac/',true);
   }
 
+
   /** @test */
   public function noLinkPretsShouldBePresent() {
     $this->assertNotXPath('//div[@id="boite_login"]//a[contains(@href, "prets")]');
   }
 
+
   /** @test */
   public function linkSeDeconnecterShouldBePresent() {
     $this->assertXPath('//div[@id="boite_login"]//a[contains(@href, "auth/logout")]');
- }
+  }
 
 
   /** @test */
@@ -114,13 +120,10 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa
                                                                          'id_site' => 1,
                                                                          'fiche_sigb' => ['fiche' => $this->emprunteur_patrick]]));
 
-
-
     $this->dispatch('/opac/');
   }
 
 
-
   /** @test */
   public function redirectProfilShouldBeProfil1(){
     $this->assertXPath('//a[contains(@href,"abonne/fiche/id_profil/1")]');
@@ -162,12 +165,11 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa
     $this->dispatch('/opac/auth/login?inspector_gadget=keep',true);
     $this->assertXPath('//form//input[@type="hidden"][@name="inspector_gadget"][@value="keep"]', $this->_response->getBody());
   }
-
-
 }
 
 
 
+
 class AuthControllerAbonneSIGBLoggedLogoutTest
   extends PortailWithOneLoginModuleTestCase {
   public function setUp() {
@@ -184,6 +186,7 @@ class AuthControllerAbonneSIGBLoggedLogoutTest
 
 
 
+
 class AuthControllerWithProfilPageAbonneSIGBLoggedLogoutTest
   extends PortailWithOneLoginModuleTestCase {
   protected $_profile, $_parent_profile;
@@ -346,6 +349,7 @@ class AuthControllerNobodyLoggedActivateErrorsTest extends AuthControllerNobodyL
     $this->assertRedirect();
   }
 
+
   /** @test */
   public function withUnknownKeyShouldDisplayError() {
     $this->dispatch('/opac/auth/activeuser/c/666', true);
@@ -447,6 +451,7 @@ class AuthControllerNobodyLoggedActivateWithKohaUseCardNumberParamSuccessTest ex
 
 
 
+
 class AuthControllerNobodyLoggedAndRegistrationAllowedBoiteLoginTest
   extends AuthControllerNobodyLoggedTestCase {
   public function setUp() {
@@ -604,7 +609,6 @@ class AuthControllerNobodyLoggedAndNoRegistrationTest extends AuthControllerNobo
       ->setValeur(1);
     Class_AdminVar::getLoader()->cacheInstance($interdire_enregistrement);
 
-
     $this->dispatch('/opac/');
   }
 
@@ -622,6 +626,7 @@ class AuthControllerNobodyLoggedAndNoRegistrationTest extends AuthControllerNobo
 
 
 
+
 class AuthControllerNobodyLoggedAndNoRegistrationOnLoginPageTest extends AuthControllerNobodyLoggedTestCase {
 
   public function setUp() {
@@ -632,7 +637,6 @@ class AuthControllerNobodyLoggedAndNoRegistrationOnLoginPageTest extends AuthCon
       ->setValeur(1);
     Class_AdminVar::getLoader()->cacheInstance($interdire_enregistrement);
 
-
     $this->dispatch('/opac/auth/login');
   }
 
@@ -699,6 +703,7 @@ class AuthControllerNobodyLoggedTest extends PortailWithOneLoginModuleTestCase {
     $this->dispatch('/opac');
   }
 
+
   /**
    * @group integration
    * @test
@@ -719,6 +724,7 @@ class AuthControllerNobodyLoggedTest extends PortailWithOneLoginModuleTestCase {
     $this->assertXPath('//div[@id="boite_login"]//form[@action="/auth/boite-login/id_module/4"]');
   }
 
+
   /** @test */
   public function withRedirectParamPageShouldContainsRedirectInput() {
     $this->bootstrap();
@@ -726,6 +732,7 @@ class AuthControllerNobodyLoggedTest extends PortailWithOneLoginModuleTestCase {
     $this->assertXPath('//input[@name="redirect"][@value="/opac/paniers"]');
   }
 
+
   /** @test */
   public function pageShouldNotContainsAjoutPanierInput() {
     $this->assertNotXPath('//input[@name="ajoutPanier"]');
@@ -748,12 +755,12 @@ class AuthControllerNumilogConnectedUserDeconnexionTest extends PortailWithOneLo
    */
   public function pageShouldBeRedirectedToHome() {
     $this->assertRedirectTo('/opac');
-
   }
 }
 
 
 
+
 class AuthControllerNoLoggedTest extends AuthControllerNobodyLoggedTestCase {
   /** @test */
   public function pageAuthLoginWithServiceShouldIncludeHiddenService() {
@@ -764,6 +771,7 @@ class AuthControllerNoLoggedTest extends AuthControllerNobodyLoggedTestCase {
 
 
 
+
 class AuthControllerUserIsLoggedTest extends PortailWithOneLoginModuleTestCase {
   public function setUp() {
     parent::setUp();
@@ -785,6 +793,9 @@ class AuthControllerUserIsLoggedTest extends PortailWithOneLoginModuleTestCase {
   }
 }
 
+
+
+
 class AuthControllerUserNameIsEscaped extends PortailWithOneLoginModuleTestCase {
   public function setUp() {
     parent::setUp();
@@ -799,18 +810,21 @@ class AuthControllerUserNameIsEscaped extends PortailWithOneLoginModuleTestCase
     $this->dispatch('/opac/auth/login',true);
   }
 
+
   /** @test */
   public function userNameShouldBeEscaped() {
     $this->assertXPathContentContains("//div[@class='welcome']", "Bienvenue &lt;script&gt;Marcus");
   }
 
+
   /** @test */
   public function userSurNameShouldBeEscaped() {
     $this->assertXPathContentContains("//span[@data-name='last-name']", "&lt;script&gt;Miller");
   }
+}
+
 
 
-}
 
 class AuthControllerPseudoIsEscaped extends PortailWithOneLoginModuleTestCase {
   public function setUp() {
@@ -826,12 +840,16 @@ class AuthControllerPseudoIsEscaped extends PortailWithOneLoginModuleTestCase {
     $this->dispatch('/opac/auth/login',true);
   }
 
+
   /** @test */
   public function userPseudoShouldBeEscaped() {
     $this->assertXPathContentContains("//div[@class='welcome']", "Bienvenue &lt;script&gt;pseudo");
   }
 }
 
+
+
+
 class AuthControllerAdminIsLoggedTest extends PortailWithOneLoginModuleTestCase {
   public function setUp() {
     parent::setUp();
@@ -890,7 +908,6 @@ class AuthControllerAdminIsLoggedTest extends PortailWithOneLoginModuleTestCase
   public function lienSeDeconnecerShouldContainsClassAccountDisconnect() {
     $this->assertXPath('//div[@class="form"]/a[@class="account-disconnect"]');
   }
-
 }
 
 
@@ -905,6 +922,7 @@ class AuthControllerPostTest extends AuthControllerNobodyLoggedTestCase {
     $_SERVER['HTTP_REFERER'] = $this->_referer;
   }
 
+
   public function loggingWithOutFillingUsername() {
     $this->postDispatch('/opac/auth/boite-login?id_module=4',
                         array('username' => 'My overkill username',
@@ -924,6 +942,7 @@ class AuthControllerPostTest extends AuthControllerNobodyLoggedTestCase {
                         ['username' => 'foo', 'password' => 'bar'],true);
   }
 
+
   public function ajaxLoginWithWrongInformation() {
     $this->postDispatch('/opac/auth/ajax-login?id_module=4',
                         ['username' => 'foo',
@@ -951,6 +970,7 @@ class AuthControllerPostTest extends AuthControllerNobodyLoggedTestCase {
     $this->assertFlashMessengerContentContains('Entrez votre identifiant');
   }
 
+
   /** @test */
   public function emptyPasswordPostActionShouldDisplayFlashMessengerWithMessageEntrezVotreMotDePasse() {
     $this->loggingWithOutFillingPassword();
@@ -971,7 +991,6 @@ class AuthControllerPostTest extends AuthControllerNobodyLoggedTestCase {
     $this->assertRedirectTo($this->_referer);
     $this->assertFlashMessengerEquals([[ZendAfi_Controller_Action_Helper_FlashMessenger::NOTIFICATION => ['message' => 'Identifiant ou mot de passe incorrect.']],
                                        [ZendAfi_Controller_Action_Helper_FlashMessenger::POPUP => ['url' => '/auth/popup-login?redirect='.urlencode('/auth/panier')]]]);
-
   }
 
 
@@ -1032,7 +1051,6 @@ abstract class AuthControllerPostSimpleSuccessfulTestCase extends AuthController
                     'model_class' => null
                    ]);
 
-
     $this->_marcel = (new class() extends Class_Users {
       public function registerNotificationsOn($notifiable) {
         $notifiable->notify('Message de notification');
@@ -1057,7 +1075,6 @@ abstract class AuthControllerPostSimpleSuccessfulTestCase extends AuthController
                  return true;
                });
 
-
     $this->_web_analytics_client = Storm_Test_ObjectWrapper::mock()
       ->whenCalled('trackEvent')
       ->answers(true);
@@ -1101,6 +1118,7 @@ class AuthControllerPostSimpleSuccessfulTest extends AuthControllerPostSimpleSuc
 
 
 
+
 class AuthControllerAjaxLoginPostTest extends AuthControllerPostSimpleSuccessfulTestCase {
   public function setUp() {
     parent::setUp();
@@ -1125,6 +1143,7 @@ class AuthControllerAjaxLoginPostTest extends AuthControllerPostSimpleSuccessful
 
 
 
+
 class AuthControllerAjaxLoginWithRedirectPopupPostTest extends AuthControllerPostSimpleSuccessfulTestCase {
   public function setUp() {
     parent::setUp();
@@ -1157,6 +1176,7 @@ class AuthControllerAjaxLoginWithRedirectPopupPostTest extends AuthControllerPos
 
 
 
+
 class AuthControllerBoiteLoginPostTest extends AuthControllerPostSimpleSuccessfulTestCase {
   public function setUp() {
     parent::setUp();
@@ -1182,6 +1202,7 @@ class AuthControllerBoiteLoginPostTest extends AuthControllerPostSimpleSuccessfu
 
 
 
+
 class AuthControllerPostSimpleSuccessfulWithRedirectTest extends AuthControllerPostSimpleSuccessfulTestCase {
   public function setUp() {
     parent::setUp();
@@ -1210,7 +1231,6 @@ abstract class AuthControllerLecturaTestCase extends AuthControllerPostSimpleTes
     $this->fixture('Class_AdminVar', ['id' => 'LECTURA_DOMAIN',
                                       'valeur' => 'test.webuser.lectura.fr']);
     Class_Users::beVolatile();
-
   }
 
 
@@ -1219,9 +1239,9 @@ abstract class AuthControllerLecturaTestCase extends AuthControllerPostSimpleTes
     $_SERVER['HTTP_HOST'] = $this->server_host;
     parent::tearDown();
   }
+}
 
 
-}
 
 
 class AuthControllerPostWrongUserFromLecturaClientTest extends AuthControllerLecturaTestCase {
@@ -1230,16 +1250,18 @@ class AuthControllerPostWrongUserFromLecturaClientTest extends AuthControllerLec
     $this->postDispatch('/',
                         ['CAB' => '0007',
                          'PWD' => 'toto' ]);
-
   }
+
+
   /** @test */
   public function responseShouldContainsError() {
     $this->assertContains('error', $this->_response->getBody());
   }
-
 }
 
 
+
+
 class AuthControllerPostSuccessfulFromLecturaClientTest extends AuthControllerLecturaTestCase {
   public function setUp() {
     parent::setUp();
@@ -1255,28 +1277,30 @@ class AuthControllerPostSuccessfulFromLecturaClientTest extends AuthControllerLe
     $this->postDispatch('/',
                         ['CAB' => '0007',
                          'PWD' => 'toto' ]);
-
   }
 
+
   /** @test */
   public function controllerShouldBeAuth() {
     $this->assertEquals('auth',$this->_request->getControllerName());
   }
 
+
   /** @test */
   public function actionShouldBeLogin() {
     $this->assertEquals('login',$this->_request->getActionName());
   }
 
+
   /** @test */
   public function responseShouldContainsSuccess() {
     $this->assertContains('success', $this->_response->getBody());
   }
-
 }
 
 
 
+
 class AuthControllerPostSuccessfulFromMusicmeCASClientTest extends AuthControllerPostSimpleSuccessfulTestCase {
   public function setUp() {
     parent::setUp();
@@ -1304,7 +1328,6 @@ class AuthControllerPostSuccessfulFromMusicmeCASClientTest extends AuthControlle
 
 
 
-
 class AuthControllerFromCASClientUserConnectedTest extends AuthControllerNobodyLoggedTestCase {
   public function setUp() {
     parent::setUp();
@@ -1383,18 +1406,18 @@ class AuthControllerPostSimpleFailureTest extends AuthControllerPostSimpleTestCa
   public function setup() {
     parent::setup();
     $_SERVER['HTTP_REFERER'] = '/opac';
-
   }
 
+
   /** @test */
   public function withAuthenticationFailureResponseShouldBeRedirect() {
     $this->postDispatch('/opac/auth/login',
                         ['username' => 'foo', 'password' => 'bar']);
     $this->assertRedirectTo('/');
   }
+}
 
 
-}
 
 
 class AuthControllerLoginActionRenderTest extends AuthControllerNobodyLoggedTestCase {
@@ -1403,6 +1426,7 @@ class AuthControllerLoginActionRenderTest extends AuthControllerNobodyLoggedTest
     $this->dispatch('/opac/auth/login',true);
   }
 
+
   /** @test */
   public function authLoginShouldContainForm() {
     $this->assertXPath('//form//fieldset[contains(@id, "fieldset-login_form")]');
@@ -1416,6 +1440,8 @@ class AuthControllerLoginActionRenderTest extends AuthControllerNobodyLoggedTest
 }
 
 
+
+
 class AuthControllerLoginActionWithDefaultPreferencesRenderTest extends AuthControllerNobodyLoggedTestCase {
   public function setUp() {
     parent::setUp();
@@ -1429,26 +1455,31 @@ class AuthControllerLoginActionWithDefaultPreferencesRenderTest extends AuthCont
     $this->dispatch('/opac/auth/login',true);
   }
 
+
   /** @test */
   public function labelUserNameShouldContainIdentifiant() {
     $this->assertXPathContentContains('//label','Identifiant');
   }
 
+
   /** @test */
   public function inputPlaceholderUsernameShouldContainVotreIdentifiant() {
     $this->assertXPath('//input[contains(@placeholder, "")]');
   }
 
+
   /** @test */
   public function labelPasswordShouldContainMotDePasse() {
     $this->assertXPathContentContains('//label','Mot de passe');
   }
 
+
   /** @test */
   public function inputPlaceholderPasswordShouldContainVotreMotDePasse() {
     $this->assertXPath('//input[contains(@placeholder, "")]');
   }
 
+
   /** @test */
   public function linkConnectionShouldHaveOnclickAttributeWithSubmit() {
     $this->assertXPath('//a[contains(@onclick, "submit")]');
@@ -1517,6 +1548,7 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedRegisterTest
 
 
 
+
 class AuthControllerNobodyLoggedAndRegistrationAllowedWithOptionalFieldsRegisterTest
   extends AuthControllerNobodyLoggedTestCase {
 
@@ -1588,7 +1620,6 @@ abstract class AuthControllerNobodyLoggedRegisterActionTestCase extends AuthCont
 
     Class_AdminVar::newInstanceWithId('REGISTER_OK', ['valeur' => '']);
 
-
     Class_AdminVar::newInstanceWithId('INTERDIRE_ENREG_UTIL', ['valeur' => 0]);
   }
 
@@ -1614,7 +1645,6 @@ class AuthControllerNobodyLoggedRegisterPostRightDatasTest
     Class_User_Registration::setTimeSource($time_source);
     $_SERVER['HTTPS'] = 'On';
 
-
     Class_Profil::getCurrentProfil()
       ->setLibelle('Nôtre cœeur')
       ->save();
@@ -1715,6 +1745,8 @@ class AuthControllerNobodyLoggedRegisterPostRightDatasTest
 }
 
 
+
+
 class AuthControllerNobodyLoggedRegisterSendBibNotification extends AuthControllerNobodyLoggedRegisterActionTestCase {
   protected
     $_sent_mails;
@@ -1811,6 +1843,9 @@ class AuthControllerNobodyLoggedRegisterSendBibNotification extends AuthControll
   }
 }
 
+
+
+
 class AuthControllerNobodyLoggedRegisterPostSendMailErrorsTest extends AuthControllerNobodyLoggedRegisterActionTestCase {
   public function setUp() {
     parent::setUp();
@@ -1820,7 +1855,6 @@ class AuthControllerNobodyLoggedRegisterPostSendMailErrorsTest extends AuthContr
                                       throw new Zend_Mail_Exception('unable to deliver mail');
                                     });
 
-
     $this->postDispatch('auth/register',
                         ['login' => 'mario',
                          'mail' => 'mario@afi-sa.fr',
@@ -1831,6 +1865,7 @@ class AuthControllerNobodyLoggedRegisterPostSendMailErrorsTest extends AuthContr
                                        'input' => '1234']]);
   }
 
+
   /** @test */
   public function pageShouldDisplayErrorUnableToDeliverMail() {
     $this->assertXPathContentContains('//p[@class="error"]', 'unable to deliver mail');
@@ -1857,6 +1892,7 @@ class AuthControllerNobodyLoggedRegisterPostWrongDataTest extends AuthController
     Class_AdminVar::newInstanceWithId('INTERDIRE_ENREG_UTIL', ['valeur' => 0]);
   }
 
+
   public function fields() {
     return [
             ['login',],
@@ -1894,11 +1930,10 @@ class AuthControllerNobodyLoggedRegisterPostWrongDataTest extends AuthController
                          'mail2' => 'blib']);
     $this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="mail"]]//li',
                                       "'blib' n'est pas un email valide de la forme 'compte@hote.ext'");
-
   }
 
 
-    /** @test */
+  /** @test */
   public function withWebSiteForSpamBotsNotEmptyShouldRedirectToRoot() {
     $this->postDispatch('auth/register',
                         ['login' => 'mario',
@@ -1911,7 +1946,6 @@ class AuthControllerNobodyLoggedRegisterPostWrongDataTest extends AuthController
                          'website' => 'something.somewhere.com']);
 
     $this->assertRedirectTo('/');
-
   }
 
 
@@ -2000,7 +2034,6 @@ class PortailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerT
       ->setBrowser('opac')
       ->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil));
 
-
     ZendAfi_Auth::getInstance()->logUser(
                                          $this->fixture('Class_Users',
                                                         ['id' => 5,
@@ -2039,11 +2072,11 @@ class PortailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerT
   public function redirectProfilForLogoutShouldNotBeProfil0(){
     $this->assertNotXPath('//a[contains(@href,"auth/logout/id_profil/")]');
   }
-
 }
 
 
 
+
 class AuthControllerAbonneSIGBNotValidLoggedTest extends PortailWithOneLoginModuleTestCase {
   public function setUp() {
     parent::setUp();
@@ -2070,6 +2103,7 @@ class AuthControllerAbonneSIGBNotValidLoggedTest extends PortailWithOneLoginModu
 
 
 
+
 class AuthControllerNobodyLoggedAndRegisterNewsletterWithNoNewsletterTest extends AuthControllerNobodyLoggedTestCase {
 
   public function setUp() {
@@ -2087,6 +2121,7 @@ class AuthControllerNobodyLoggedAndRegisterNewsletterWithNoNewsletterTest extend
 
 
 
+
 class AuthControllerNobodyLoggedAndRegisterNewsletterWithWrongNewsletterTest extends AuthControllerNobodyLoggedTestCase {
 
   public function setUp() {
@@ -2323,6 +2358,7 @@ class AuthControllerPostRegisterNewsletterDailyNewsWithBadMailTest extends AuthC
                                                                 'website' => '']);
   }
 
+
   /** @test */
   public function shouldDisplayValidationError() {
     $this->assertXPathContentContains('//ul[@class="errors"]/li', 'n\'est pas un email valide');
@@ -2377,6 +2413,7 @@ class AuthControllerNewsletterActiveUserWithWrongParamsTest
 
 
 
+
 class AuthControllerNewsletterActiveUserTest extends AuthControllerNoBodyLoggedTestCase {
   public function setUp() {
     parent::setUp();
@@ -2421,6 +2458,7 @@ class AuthControllerNewsletterActiveUserTest extends AuthControllerNoBodyLoggedT
     $this->assertMIMEPartContains($needle, $this->mails[0]->getBodyHtml());
   }
 
+
   /** @test */
   public function userFutureShouldExist() {
     $this->assertEquals('future@i.am',
@@ -2520,6 +2558,7 @@ class AuthControllerTomLoggedRegisterNewsletterTestCase extends AbstractControll
 
 
 
+
 class AuthControllerNewsletterUnsubscribeNoBodyTest extends AuthControllerNobodyLoggedTestCase {
 
   public function setUp() {
@@ -2530,7 +2569,6 @@ class AuthControllerNewsletterUnsubscribeNoBodyTest extends AuthControllerNobody
                     'mail_subject' => 'Daily News',
                     'titre' => 'Daily News']);
 
-
     $this->dispatch('auth/newsletter-unsubscribe/id/10', true);
   }
 
@@ -2608,6 +2646,7 @@ class AuthControllerNewsletterUnsubscribeTest extends AbstractControllerTestCase
 
 
 
+
 class AuthControllerNewsletterRegisterSendMailWrongMailConfigurationTest extends AbstractControllerTestCase {
   protected $_storm_default_to_volatile = true;
 
@@ -2619,7 +2658,7 @@ class AuthControllerNewsletterRegisterSendMailWrongMailConfigurationTest extends
     $this->mock_transport = new MockMailTransport();
     Zend_Mail::setDefaultTransport($this->mock_transport);
     $this->mock_transport->onSendDo(function() { throw new Exception();
-                                                });
+    });
 
     Class_Profil::getCurrentProfil()
       ->setMailSite('tom@afi.fr');
@@ -2641,6 +2680,7 @@ class AuthControllerNewsletterRegisterSendMailWrongMailConfigurationTest extends
 
 
 
+
 class AuthControllerNewsletterRegisterWithAutoSubscribeNewsletterTest extends AbstractControllerTestCase {
   protected $_storm_default_to_volatile = true;
 
@@ -2654,7 +2694,6 @@ class AuthControllerNewsletterRegisterWithAutoSubscribeNewsletterTest extends Ab
                                            'password' => 'random',
                                            'cle' => '12345678']);
 
-
     $this->dispatch('opac/auth/newsletter-active-user/c/12345678/id/2', true);
   }
 
@@ -2727,7 +2766,7 @@ class AuthControllerPostWithSameIdSigbTest extends AbstractControllerTestCase {
                     'comm_sigb' => 5,
                     'comm_params' => serialize($params)]);
 
-   $this->fixture('Class_Bib',
+    $this->fixture('Class_Bib',
                    ['id' => 13,
                     'libelle' => 'First library']);
 
@@ -2771,6 +2810,7 @@ class AuthControllerPostWithSameIdSigbTest extends AbstractControllerTestCase {
 
 
 
+
 class AuthControllerPostLoginWithDifferentIdIntBibTest
   extends AbstractControllerTestCase {
   protected $_storm_default_to_volatile = true;
@@ -2796,14 +2836,12 @@ class AuthControllerPostLoginWithDifferentIdIntBibTest
     $emprunteur->beValid();
 
     $service = Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
-                    ->whenCalled('getEmprunteur')
-                    ->answers($emprunteur)
-
-                    ->whenCalled('isConnected')
-                    ->answers(true)
-
-                    ->whenCalled('providesAuthentication')
-                    ->answers(true);
+      ->whenCalled('getEmprunteur')
+      ->answers($emprunteur)
+      ->whenCalled('isConnected')
+      ->answers(true)
+      ->whenCalled('providesAuthentication')
+      ->answers(true);
 
     $params = ['url_serveur' => 'http://mon-koha-de-test.org',
                'id_bib' => 56,
@@ -2871,20 +2909,19 @@ class AuthControllerPostLoginOpsysWithExceptionTest extends AbstractControllerTe
                    ['id' => 44 ,
                     'comm_sigb' => Class_IntBib::COM_OPSYS,
                     'comm_params' => serialize(['url_serveur' => ''])]);
-
-    $service = $this->mock()
-                    ->whenCalled('providesAuthentication')->answers(true)
-                    ->whenCalled('isConnected')->answers(true)
-                    ->whenCalled('providesPagedLoans')->answers(false)
-
-                    ->whenCalled('getEmprunteur')
-                    ->answers(Class_WebService_SIGB_Emprunteur::newInstance(2233, 'harlock')->beValid())
-
-                    ->whenCalled('getEmpruntsOf')
-                    ->willDo(function()
-                             {
-                               throw new SoapFault('1512', 'Character reference "&#x1E" is an invalid XML character');
-                             });
+    $service = Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
+      ->whenCalled('getEmprunteur')
+      ->answers(Class_WebService_SIGB_Emprunteur::newInstance(2233, 'harlock')->beValid())
+      ->whenCalled('isConnected')
+      ->answers(true)
+      ->whenCalled('getEmpruntsOf')
+      ->willDo(function()
+      {
+        throw new SoapFault('1512', 'Character reference "&#x1E" is an invalid XML character');
+      })
+      ->whenCalled('providesPagedLoans')->answers(false)
+      ->whenCalled('providesAuthentication')
+      ->answers(true);
 
     Class_WebService_SIGB_Opsys::setService($service);
 
@@ -2939,3 +2976,119 @@ class AuthControllerFooBarConnectionTest extends AbstractControllerTestCase {
                         Class_Users::getIdentity()->getLastLogin());
   }
 }
+
+
+
+
+class AuthControllerOrpheeTest
+  extends AbstractControllerTestCase {
+  protected $_orphee;
+
+  public function setUp() {
+    parent::setUp();
+    Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY', 1);
+    Class_WebService_SIGB_Orphee::reset();
+    $comm_params = ['url_serveur' => 'http://localhost',
+                    'key' => '0',
+                    'identification_server_provider' =>true,
+                    'allow_hold_available_items' => ''];
+
+    $this->fixture(Class_IntBib::class,
+                   ['id' => 3,
+                    'comm_params' => $comm_params,
+                    'comm_sigb' => Class_IntBib::COM_ORPHEE
+                   ]);
+    $comm_params_other = ['url_serveur' => 'http://other/',
+                          'key' => '0',
+                          'identification_server_provider' =>false,
+                          'allow_hold_available_items' => ''];
+    $this->fixture(Class_Bib::class,
+                   ['id' => 5,
+                    'libelle' => 'Aubrac']);
+
+    $this->fixture(Class_CodifAnnexe::class,
+                   ['id' => 5,
+                    'id_origine' => '17',
+                    'libelle' => 'Aurillac',
+                    'id_bib'=> 7]);
+
+    $this->fixture(Class_IntBib::class,
+                   ['id' => 7,
+                    'comm_params' => $comm_params_other,
+                    'comm_sigb' => Class_IntBib::COM_ORPHEE
+                   ]);
+
+    $client = $this->mock()
+                   ->whenCalled('__setCookie')
+                   ->answers(null)
+
+                   ->whenCalled('EndSession')
+                   ->answers(new EndSessionResponse())
+
+                   ->whenCalled('hasFunction')->with('GetAdh')->answers(true)
+                   ->whenCalled('hasFunction')->with('GetId')->answers(true)
+                   ->whenCalled('GetId')
+                   ->answers(new GetIdResponse())
+                   ->whenCalled('GetAdh')
+                   ->answers(GetAdhResponse::withResult(
+                                                        OrpheeFixtures::xmlGetInfoUserCarteHenryDupont()));
+    $this->_orphee = new Class_WebService_SIGB_Orphee_ServiceForTesting($client);
+    $this->_orphee->setSessionStrategy( Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
+                                        ->whenCalled('isConnected')->answers(true)
+                                        ->whenCalled('disconnect')->answers(true));
+
+    $orphee_other = new Class_WebService_SIGB_Orphee_ServiceForTesting($client);
+
+    Class_WebService_SIGB_Orphee::setService(array_merge($comm_params,
+                                                         ['id_bib' => 3,
+                                                          'type' => Class_IntBib::COM_ORPHEE]), $this->_orphee);
+
+    Class_WebService_SIGB_Orphee::setService(array_merge($comm_params_other,
+                                                         ['id_bib' => 7,
+                                                          'type' => Class_IntBib::COM_ORPHEE]), $orphee_other);
+
+    ZendAfi_Auth::getInstance()->clearIdentity();
+
+    Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY', '1');
+
+    Class_User_Log::setTimeSource(new TimeSourceForTest('2020-06-06 14:14:14'));
+  }
+
+
+  public function tearDown() {
+    Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY', '0');
+    $this->_orphee->setSearchClient(null)->setSessionStrategy(null);
+    Class_WebService_SIGB_Orphee::reset();
+    parent::tearDown();
+  }
+
+
+  /** @test */
+  public function withUnknownloanerInDbShouldBeCreatedWithBib(){
+    $this->postDispatch('/opac/auth/login',
+                        ['username' => '0010900000753', 'password' => 'bar']);
+
+    $this->assertEquals(7,
+                        Class_Users::findFirstBy([ 'id_sigb' => '100753'])->getIdIntBib());
+  }
+
+
+  /** @test */
+  public function withExistingLoanerInDbShouldBeCreatedWithRightBib(){
+    $user = $this->fixture(Class_Users::class,
+                           ['id' => 2,
+                            'login' => '0010900000753',
+                            'idabon' => '0010900000753',
+                            'id_sigb' => '100753',
+                            'password' => 'secret',
+                            'int_bib' => Class_IntBib::find(3),
+                            'bib' => Class_Bib::find(5)]);
+    $user->beAbonneSIGB()->assertSave();
+
+    $this->postDispatch('/opac/auth/login',
+                        ['username' => '0010900000753', 'password' => 'bar']);
+
+    $this->assertEquals(7,
+                        Class_Users::findFirstBy([ 'login' => '0010900000753'])->getIdIntBib());
+  }
+}
diff --git a/tests/application/modules/opac/controllers/MultimediaControllerTest.php b/tests/application/modules/opac/controllers/MultimediaControllerTest.php
index 92dbd353444ad56cf3ca649655c8f72f1dae5b19..8755e5e86993b8f6ed77598cc8f767ef8e2b81ca 100644
--- a/tests/application/modules/opac/controllers/MultimediaControllerTest.php
+++ b/tests/application/modules/opac/controllers/MultimediaControllerTest.php
@@ -359,6 +359,7 @@ class MultimediaControllerAuthenticateLaurentDeviceNotHeldByUserTest
     ZendAfi_Auth::getInstance()->clearIdentity();
 
     Class_Multimedia_Location::setTimeSource(new TimeSourceForTest('2022-11-25 09:00:00'));
+    Class_Multimedia_Device::setTimeSource(new TimeSourceForTest('2022-11-25 09:00:00'));
 
     $ouverture =
       $this->fixture(Class_Ouverture::class,
@@ -423,6 +424,13 @@ class MultimediaControllerAuthenticateLaurentDeviceNotHeldByUserTest
   }
 
 
+  public function tearDown() {
+    Class_Multimedia_Device::setTimeSource(null);
+    Class_Multimedia_Location::setTimeSource(null);
+    parent::tearDown();
+  }
+
+
   /** @test */
   public function shouldReturnNotHeldByUser() {
     $this->assertEquals('{"auth":0,"id":8,"login":"laurent","password":"afi","mail":"lolo@mail.fr","nom":"laffont","prenom":"laurent","date_debut":null,"date_fin":null,"groupes":["adulte","abonne","abonne_sigb","Devs Agiles"],"cardnumber":"bca2","date_naissance":"1978\/02\/17","error":"DeviceNotHeldByUser"}',
@@ -494,6 +502,13 @@ class MultimediaControllerAuthenticateLaurentDeviceNotFoundTest
   }
 
 
+
+  public function tearDown() {
+    Class_Multimedia_Location::setTimeSource(null);
+    parent::tearDown();
+  }
+
+
   /** @test */
   public function shouldReturnDeviceNotFound() {
     $this->assertEquals('{"auth":0,"id":8,"login":"laurent","password":"afi","mail":"lolo@mail.fr","nom":"laffont","prenom":"laurent","date_debut":null,"date_fin":null,"groupes":["adulte","abonne","abonne_sigb","Devs Agiles"],"cardnumber":"bca2","date_naissance":"1978\/02\/17","error":"DeviceNotFound"}',
@@ -592,4 +607,4 @@ class MultimediaControllerAuthenticateNanookBorrowerFromAfiMultimediaTest
   public function axelMultimediaAccessShouldBeUpdatedToOne() {
     $this->assertEquals(0, Class_Users::find(890)->getMultimediaAccess());
   }
-}
\ No newline at end of file
+}
diff --git a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php
index 766c9d6de2fd274b74885f3f94ed1e8380e252f7..f0da56e8ef705bf9d8f2afb32358ab6dc3f85be3 100644
--- a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php
+++ b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php
@@ -433,7 +433,7 @@ class RechercheControllerReservationWithWebServiceKohaTest
                                  ]);
 
     ZendAfi_Auth::getInstance()->logUser($this->jajm);
-    $this->koha = Storm_Test_ObjectWrapper::mock();
+    $this->koha = Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService());
     $this->koha
       ->whenCalled('getServerRoot')
       ->answers($webservice);
@@ -634,7 +634,8 @@ class RechercheControllerReservationSerialWithWebServiceKohaTest
     Class_AdminVar::set('KOHA_MULTI_SITES','1');
 
     ZendAfi_Auth::getInstance()->logUser($this->jajm);
-    $this->koha = Storm_Test_ObjectWrapper::mock();
+    $this->koha = Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService());
+
     $this->koha
       ->whenCalled('getServerRoot')
       ->answers($webservice);
diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php
index 52e5c410bdb0161378c4b60e2adeec255e03e33a..1207e4eedc714e5eeea7d6f509407409f6277b55 100644
--- a/tests/db/UpgradeDBTest.php
+++ b/tests/db/UpgradeDBTest.php
@@ -5294,3 +5294,13 @@ class UpgradeDB_451_Test extends UpgradeDBTestCase {
     $this->assertPrimary('user_watched_selection', 'id');
   }
 }
+
+
+
+
+class UpgradeDB_452_Test extends UpgradeDBTestCase {
+  public function prepare() {}
+
+  /** @test */
+  public function placeholderForCommSigbOrpheePatch() {}
+}
diff --git a/tests/library/Class/Migration/CommSigbOrpheeTest.php b/tests/library/Class/Migration/CommSigbOrpheeTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..c5a994567e542a3a674c87ddd02e29e3931ee16b
--- /dev/null
+++ b/tests/library/Class/Migration/CommSigbOrpheeTest.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Copyright (c) 2012-2021, 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 Class_Migration_CommSigbOrpheeTest extends ModelTestCase {
+
+  public function setUp() {
+    parent::setUp();
+    $int_bib = $this->fixture(Class_IntBib::class,
+                              ['id' => 5,
+                               'comm_sigb' => Class_IntBib::COM_KOHA]);
+  }
+
+
+  public function tearDown() {
+    Class_Migration_UpdateDatabaseAfterSelectDb::setAdapter(null);
+    parent::tearDown();
+  }
+
+
+  /** @test */
+  public function withNoOrpheeShouldDoNothing() {
+    (new Class_Migration_CommSigbOrphee)->run();
+    $this->assertFalse(isset(Class_IntBib::find(5)->getCommParamsAsArray()['identification_server_provider']));
+  }
+
+
+  /** @test */
+  public function withOrpheeShouldSetIdServerProviderToTrue() {
+    $int_bib = $this->fixture(Class_IntBib::class,
+                              ['id' => 6,
+                               'comm_sigb' => Class_IntBib::COM_ORPHEE]);
+
+    $int_bib2 = $this->fixture(Class_IntBib::class,
+                               ['id' => 7,
+                                'comm_sigb' => Class_IntBib::COM_ORPHEE]);
+
+    $int_bib_already_set = $this->fixture(Class_IntBib::class,
+                                          ['id' => 8,
+                                           'comm_sigb' => Class_IntBib::COM_ORPHEE]);
+    $params = $int_bib_already_set->getCommParamsAsArray();
+    $params['identification_server_provider']=false;
+    $int_bib_already_set->setCommParams($params)->save();
+    (new Class_Migration_CommSigbOrphee)->run();
+    $this->assertTrue($int_bib->getCommParamsAsArray()['identification_server_provider']);
+    $this->assertTrue($int_bib2->getCommParamsAsArray()['identification_server_provider']);
+    $this->assertFalse($int_bib_already_set->getCommParamsAsArray()['identification_server_provider']);
+  }
+}
diff --git a/tests/library/Class/WebService/SIGB/OrpheeFixtures.php b/tests/library/Class/WebService/SIGB/OrpheeFixtures.php
index 76419063c1ed33aec28187e9f7c1c582e9741587..75ab53e89d8468baa742dbb28477b89656b308da 100644
--- a/tests/library/Class/WebService/SIGB/OrpheeFixtures.php
+++ b/tests/library/Class/WebService/SIGB/OrpheeFixtures.php
@@ -530,7 +530,7 @@ class OrpheeFixtures {
   <bloquee><![CDATA[0]]></bloquee>    <!--Est-ce que l’adhérent est bloqué -->
   <cat_pret><![CDATA[1]]></cat_pret>   <!-- Catégorie de prêt -->
   <lib_cat_pret><![CDATA[Lecteur adulte]]></lib_cat_pret>  <!-- Libellé de sa catégorie de pret -->
-  <anx><![CDATA[1]]></anx>    <!-- Bibliothèque de l’adhérent -->
+  <anx><![CDATA[17]]></anx>    <!-- Bibliothèque de l’adhérent -->
   <lib_anx><![CDATA[ Aurillac]]></lib_anx>  <!-- Nom de la bibliothèque de l’adhérent -->
   <date_renouv><![CDATA[01/03/2010]]></date_renouv>  <!-- Date de renouvellement de l\'adhésion -->
   <nb_prets><![CDATA[1]]></nb_prets>    <!-- Nombre de prêts de l\'adhérent -->
@@ -786,4 +786,30 @@ renouvellement -->
     return '<?xml version="1.0" encoding="utf-8"?><datas><infos><nb_res><![CDATA[11]]></nb_res></infos><documents><document><ntc><![CDATA[472024717]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[231054]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002310543]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Cuisine et vins de France]]></titre><editeur><![CDATA[Marie-Claire Album]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[22/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[354050841]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[237009]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002370091]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Adultes]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Le Carrer, Olivier (1955-....)]]></auteur><cote><![CDATA[133.1 LEC]]></cote><titre><![CDATA[Atlas des lieux maudits]]></titre><editeur><![CDATA[Arthaud]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[2]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[22/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1300600674]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[133858]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001338586]]></cb><lib_sup><![CDATA[ DVD]]></lib_sup><sup><![CDATA[114]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Porte, Gilles]]></auteur><cote><![CDATA[F POR]]></cote><titre><![CDATA[Quand la mer monte]]></titre><editeur><![CDATA[Ognon pictures]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[22/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[354666415]]></ntc><date_ret><![CDATA[13/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[234221]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002342215]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Adultes]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Campbell, James W. P]]></auteur><cote><![CDATA[027 CAM]]></cote><titre><![CDATA[Bibliothèques]]></titre><editeur><![CDATA[Citadelles & Mazenod]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[2]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[01/04/2015]]></date_pret><nprol><![CDATA[1]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[472024717]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[214356]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002143563]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Cuisine et vins de France]]></titre><editeur><![CDATA[Marie-Claire Album]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[472024717]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[191095]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001910954]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Cuisine et vins de France]]></titre><editeur><![CDATA[Marie-Claire Album]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1301002547]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[143359]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001433593]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Dimery, Robert]]></auteur><cote><![CDATA[782 DIM]]></cote><titre><![CDATA[Les 1001 albums qu\'il faut avoir écoutés dans sa vie : rock, hip hop, soul dance, techno ...]]></titre><editeur><![CDATA[Flammarion]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1414909049]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[195118]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106001951180]]></cb><lib_sup><![CDATA[ DVD]]></lib_sup><sup><![CDATA[114]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Bonvoisin, Bernie]]></auteur><cote><![CDATA[F BON]]></cote><titre><![CDATA[Les démons de Jésus]]></titre><editeur><![CDATA[Studio Canal vidéo]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[134321153]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[212098]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002120983]]></cb><lib_sup><![CDATA[ CD]]></lib_sup><sup><![CDATA[110]]></sup><lib_section><![CDATA[Consultation]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Jarrett, Keith]]></auteur><cote><![CDATA[1.3 JAR]]></cote><titre><![CDATA[Hymns, spheres]]></titre><editeur /><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[8]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1301003693]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[234801]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002348014]]></cb><lib_sup><![CDATA[ Périodique]]></lib_sup><sup><![CDATA[112]]></sup><lib_section><![CDATA[Accueil]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur /><cote /><titre><![CDATA[Sciences humaines]]></titre><editeur><![CDATA[Sciences humaines éditions]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[9]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document><document><ntc><![CDATA[1314912055]]></ntc><date_ret><![CDATA[12/05/2015]]></date_ret><anx_ori><![CDATA[1]]></anx_ori><no><![CDATA[203232]]></no><is_nouv><![CDATA[False]]></is_nouv><cb><![CDATA[00106002032329]]></cb><lib_sup><![CDATA[ Livre]]></lib_sup><sup><![CDATA[108]]></sup><lib_section><![CDATA[Adultes]]></lib_section><lib_uti><![CDATA[prêt normal]]></lib_uti><auteur><![CDATA[Leroux, Léonnard (1977-....)]]></auteur><cote><![CDATA[248.4 LER]]></cote><titre><![CDATA[En chemin vers Compostelle]]></titre><editeur><![CDATA[Presses de la Renaissance]]></editeur><is_retard><![CDATA[False]]></is_retard><is_rsv><![CDATA[False]]></is_rsv><sec><![CDATA[2]]></sec><uti><![CDATA[2]]></uti><date_pret><![CDATA[18/04/2015]]></date_pret><nprol><![CDATA[0]]></nprol><nrel><![CDATA[0]]></nrel></document></documents></datas>';
   }
 }
+
+
+
+
+class Class_WebService_SIGB_Orphee_ServiceForTesting extends Class_WebService_SIGB_Orphee_Service {
+  public function __construct($search_client) {
+    $this->_provided_search_client = $search_client;
+  }
+
+
+  public function getSearchClient() {
+    $this->_search_client = $this->_provided_search_client;
+    $result = $this->_search_client->GetId(new GetId());
+    $this->_guid = $result->GetIdResult;
+    $this->_search_client->__setCookie('ASP.NET_SessionId', $this->_guid);
+    return $this->_search_client;
+  }
+
+
+  public function getExemplaire(string $id_origine, string $barcode) {
+    return
+      $this->getILSWsItemFromCacheOrRequest((Class_Exemplaire::findFirstBy(['id_origine' => $id_origine,
+                                                                            'code_barres' => $barcode])) ?? new Class_Exemplaire);
+  }
+}
+
 ?>
diff --git a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
index 7ab6e512e50403e0b2d32321439d725840757996..e8fe47020d2b87e5841fb54caced06ecd9aba0d1 100644
--- a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
+++ b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
@@ -25,28 +25,6 @@ include_once('Class/WebService/SIGB/Orphee/SessionStrategy.php');
 include_once('OrpheeFixtures.php');
 
 
-class Class_WebService_SIGB_Orphee_ServiceForTesting extends Class_WebService_SIGB_Orphee_Service {
-  public function __construct($search_client) {
-    $this->_provided_search_client = $search_client;
-  }
-
-
-  public function getSearchClient() {
-    $this->_search_client = $this->_provided_search_client;
-    $result = $this->_search_client->GetId(new GetId());
-    $this->_guid = $result->GetIdResult;
-    $this->_search_client->__setCookie('ASP.NET_SessionId', $this->_guid);
-    return $this->_search_client;
-  }
-
-
-  public function getExemplaire(string $id_origine, string $barcode) {
-    return
-      $this->getILSWsItemFromCacheOrRequest((Class_Exemplaire::findFirstBy(['id_origine' => $id_origine,
-                                                                            'code_barres' => $barcode])) ?? new Class_Exemplaire);
-  }
-}
-
 
 
 
@@ -1065,7 +1043,6 @@ class OrpheeServiceGetInfoUserCarteHenryDupontTest extends OrpheeServiceTestCase
     $this->assertNotEmpty($this->emprunteur);
   }
 
-
   /** @test */
   public function emprunteurShouldNotBeBlocked() {
     $this->assertFalse($this->emprunteur->isBlocked());
@@ -1087,8 +1064,8 @@ class OrpheeServiceGetInfoUserCarteHenryDupontTest extends OrpheeServiceTestCase
 
 
   /** @test */
-  public function emprunteurLibraryCodeShouldBeOne() {
-    $this->assertEquals(1, $this->emprunteur->getLibraryCode());
+  public function emprunteurLibraryCodeShouldSeventeen() {
+    $this->assertEquals(17, $this->emprunteur->getLibraryCode());
   }
 
 
diff --git a/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php b/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php
index 7b3f39987238ec1af45a05d59f7a6c2a217ddc6a..3661625823b8b0f59e0fa1222314ca1a7d2f7359 100644
--- a/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php
+++ b/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php
@@ -117,7 +117,7 @@ abstract class AuthCommSigbWithWebServicesAndAbonneZorkTestCase extends AuthComm
                     'type_fichier' => Class_IntProfilDonnees::FT_PATRONS]);
 
     Class_WebService_SIGB_Nanook::setService($nanook_comm_params,
-                                             $this->nanook = $this->mock()
+                                             $this->nanook = Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
                                              ->whenCalled('providesAuthentication')
                                              ->answers(true));
 
@@ -138,7 +138,7 @@ abstract class AuthCommSigbWithWebServicesAndAbonneZorkTestCase extends AuthComm
                                                }
                                              });
 
-    Class_WebService_SIGB_Opsys::setService($this->opsys = $this->mock()
+    Class_WebService_SIGB_Opsys::setService($this->opsys = Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
                                             ->whenCalled('providesAuthentication')
                                             ->answers(true));
 
@@ -544,7 +544,7 @@ class AuthCommSigbWithWebServicesAndAbonneZorkAndMinimalResponseTest
                     'libelle' => 'Some patrons',
                     'type_fichier' => Class_IntProfilDonnees::FT_PATRONS]);
 
-    Class_WebService_SIGB_Opsys::setService($this->opsys = $this->mock()
+    Class_WebService_SIGB_Opsys::setService($this->opsys = Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
                                             ->whenCalled('providesAuthentication')
                                             ->answers(true));
 
diff --git a/tests/library/ZendAfi/AuthTest.php b/tests/library/ZendAfi/AuthTest.php
index 594f896b117a5c886506df6ccfb734f3c2610e55..8c5533e77489c72c91b3cd56138fa54407b8dd35 100644
--- a/tests/library/ZendAfi/AuthTest.php
+++ b/tests/library/ZendAfi/AuthTest.php
@@ -142,7 +142,7 @@ abstract class AuthWithConfiguredNanookTestCase extends ModelTestCase {
     $this->fixture('Class_Bib', ['id' => 3,
                                  'visibilite' => Class_Bib::V_DATA]);
 
-    $this->_nanook = $this->mock()
+    $this->_nanook =  Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
                           ->whenCalled('getEmprunteur')
                           ->answers(Class_WebService_SIGB_Emprunteur::nullInstance())
 
@@ -300,4 +300,4 @@ class Mock_AuthDB extends Class_Entity implements Zend_Auth_Adapter_Interface {
   public function authenticate() {
     return new Zend_Auth_Result($this->_result, $this->getIdentity());
   }
-}
\ No newline at end of file
+}
diff --git a/tests/scenarios/MultiCards/MultiCardsAddCardTest.php b/tests/scenarios/MultiCards/MultiCardsAddCardTest.php
index a930e1c1c6f8d0e42e99a93bfe84d670b21ed5a0..5e2876684eb6ae9d22edaf583b69cc558e04c544 100644
--- a/tests/scenarios/MultiCards/MultiCardsAddCardTest.php
+++ b/tests/scenarios/MultiCards/MultiCardsAddCardTest.php
@@ -290,9 +290,8 @@ class Scenario_AbonneMultiCardsAddCardFromNanookWithSameIdabonTest
                                                        ['id' => 1,
                                                         'type_fichier' => Class_IntProfilDonnees::FT_PATRONS])]);
 
-    $nanook_service = $this->mock()
+    $nanook_service =  Storm_Test_ObjectWrapper::on(new Class_WebService_SIGB_TestingService())
                            ->whenCalled('providesAuthentication')->answers(true)
-                           ->whenCalled('hasNetworkError')->answers(false)
                            ->whenCalled('getServerRoot')->answers($comm_params['url_serveur'])
 
                            ->whenCalled('getEmprunteur')