From 53f4d8a0627159d645985cc14812ab00fd8fdb91 Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Thu, 14 Mar 2024 15:03:07 +0100
Subject: [PATCH] [RTko] hotline#198092 : fix an error when getting user annexe
 from Decalog

---
 VERSIONS_HOTLINE/198092                       |  1 +
 .../Class/WebService/SIGB/Decalog/Service.php |  2 +-
 .../Class/WebService/SIGB/DecalogTest.php     | 30 +++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 VERSIONS_HOTLINE/198092

diff --git a/VERSIONS_HOTLINE/198092 b/VERSIONS_HOTLINE/198092
new file mode 100644
index 00000000000..21bf19d4e46
--- /dev/null
+++ b/VERSIONS_HOTLINE/198092
@@ -0,0 +1 @@
+ - correctif #198092 : Exemplaire : La réservation doit fonctionner pour le connecteur Decalog.
\ No newline at end of file
diff --git a/library/Class/WebService/SIGB/Decalog/Service.php b/library/Class/WebService/SIGB/Decalog/Service.php
index 9d5847fcc4d..ec96ed04e44 100644
--- a/library/Class/WebService/SIGB/Decalog/Service.php
+++ b/library/Class/WebService/SIGB/Decalog/Service.php
@@ -79,7 +79,7 @@ class Class_WebService_SIGB_Decalog_Service extends Class_WebService_SIGB_Abstra
 
 
   public function getUserAnnexe($user) : int {
-    return  $annexe = Class_CodifAnnexe::findFirstBy([ 'id_bib' => $user->getIdIntBib()])
+    return ($annexe = Class_CodifAnnexe::findFirstBy(['id_bib' => $user->getIdIntBib()]))
       ? $annexe->getIdOrigine()
       : 0;
   }
diff --git a/tests/library/Class/WebService/SIGB/DecalogTest.php b/tests/library/Class/WebService/SIGB/DecalogTest.php
index 6bedc694278..1ba97343be8 100644
--- a/tests/library/Class/WebService/SIGB/DecalogTest.php
+++ b/tests/library/Class/WebService/SIGB/DecalogTest.php
@@ -720,3 +720,33 @@ class DecalogSaveEmprunteurTest extends DecalogAuthenticationTest {
     $this->assertEquals(['statut' => true, 'erreur' => false], $response);
   }
 }
+
+
+
+
+class DecalogGetUserAnnexeTest extends DecalogTestCase {
+
+  protected $_jlurcat;
+
+  public function setUp() {
+    parent::setUp();
+
+    $this->fixture(Class_CodifAnnexe::class, ['id' => 4,
+                                              'id_bib' => 3,
+                                              'libelle' => 'Bibliothèque de Lunel-Viel',
+                                              'invisible' => 0,
+                                              'id_origine' => 6457987987]);
+
+    $this->_jlurcat = $this->fixture(Class_Users::class, ['id' => '23200',
+                                                          'login' => 'jlurcat',
+                                                          'password' => 'tapstry',
+                                                          'idabon' => '9898',
+                                                          'id_int_bib' => 3]);
+  }
+
+
+  /** @test */
+  public function getUserAnnexeShouldReturn6457987987() {
+    $this->assertEquals(6457987987, $this->_service->getUserAnnexe($this->_jlurcat));
+  }
+}
-- 
GitLab