From 93011c06139a74b2adad7902b82f217096ee7340 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?ANDRE=20s=C3=A9bastien?= <sandre@afi-sa.fr>
Date: Thu, 8 Jun 2023 09:10:10 +0000
Subject: [PATCH] hotline : #179619 : missing return

---
 VERSIONS_HOTLINE/179619                       |  1 +
 .../php/classes/KohaRecordIntegrationTest.php | 52 +++++++++++++++++++
 .../tests/php/classes/unimarc_zones.txt       |  1 +
 library/Class/NoticeUnimarc/Zone.php          |  4 +-
 4 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 VERSIONS_HOTLINE/179619
 create mode 100644 cosmogramme/tests/php/classes/unimarc_zones.txt

diff --git a/VERSIONS_HOTLINE/179619 b/VERSIONS_HOTLINE/179619
new file mode 100644
index 00000000000..354fe0b5f31
--- /dev/null
+++ b/VERSIONS_HOTLINE/179619
@@ -0,0 +1 @@
+ - correctif #179619 : Cosmogramme : fichier bloqué dans les traitements
\ No newline at end of file
diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php
index f2e98af3360..1032955e464 100644
--- a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php
+++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php
@@ -1148,3 +1148,55 @@ class NoticeIntegrationTest extends KohaRecordIntegrationTestCase {
                         Class_Notice::find(1)->getAuteurs());
   }
 }
+
+
+
+
+// hotline : https://forge.afi-sa.net/issues/179619
+class NoticeIntegrationZonesTest extends KohaRecordIntegrationTestCase {
+
+  public function setUp() {
+    parent::setUp();
+
+    Class_CosmoVar::setValueOf('other_index_fields', '995$a');
+    Class_CosmoVar::setValueOf('unimarc_zone_titre', '200$a;464$t');
+
+    $this->fixture(Class_Notice::class,
+                   ['id' => 1,
+                    'type_doc' => 1,
+                    'isbn' => '978-2-9553143-5-7']);
+
+    $this->fixture(Class_Exemplaire::class,
+                   ['id' => 51,
+                    'id_notice' => 1,
+                    'zone995' => serialize([['clef' => 'a']])]);
+
+    $this->loadNotice('unimarc_zones');
+  }
+
+
+  public function loadNoticeFromString($unimarc, $id_bib = 1) {
+    $this->notice_integration = new notice_integration();
+    $this->notice_integration->setParamsIntegration($id_bib,
+                                                    0,
+                                                    isset($this->_profil_donnees['id_profil'])
+                                                    ? $this->_profil_donnees['id_profil']
+                                                    : 1,
+                                                    'a');
+
+    $this->_service_runner = $this->mock()
+                                  ->whenCalled('run')
+                                  ->answers(['statut' => 'KO']);
+    $this->notice_integration->setServiceRunner($this->_service_runner);
+    $this->notice_integration->traiteNotice($unimarc);
+    $this->notice_integration->traiteFacettes();
+    $this->notice_data = $this->notice_integration->getNotice();
+  }
+
+
+  /** @test */
+  public function itemZone995ShouldExistWithOnlyClef() {
+    $this->assertEquals('a:1:{i:0;a:1:{s:4:"clef";s:1:"a";}}',
+                        Class_Exemplaire::find(51)->getZone995());
+  }
+}
diff --git a/cosmogramme/tests/php/classes/unimarc_zones.txt b/cosmogramme/tests/php/classes/unimarc_zones.txt
new file mode 100644
index 00000000000..302933633a6
--- /dev/null
+++ b/cosmogramme/tests/php/classes/unimarc_zones.txt
@@ -0,0 +1 @@
+00485nrm2 2200157   450 001000700000009001400007009000900021010001800030100001300048101001300061200003000074215006500104330000500169517001100174995014200185498296123456789abcdqsdf4567  a9782955314357  a20201118  afrecfre1 aLes bêbêtes à feuilles  eFeuilles mortes, yeux mobiles, 1 feuille de papier, pompons.  a  anbvcxw  aMédiathèque François-Mitterrandf105759kBKIT9m20201130jbqjrzzodv02[PIL][Pilon][1][0][][0][0][0][1]42021-05-2450714819302
\ No newline at end of file
diff --git a/library/Class/NoticeUnimarc/Zone.php b/library/Class/NoticeUnimarc/Zone.php
index 28f829ad78e..239e61a3a0d 100644
--- a/library/Class/NoticeUnimarc/Zone.php
+++ b/library/Class/NoticeUnimarc/Zone.php
@@ -65,7 +65,9 @@ class Class_NoticeUnimarc_Zone {
 
   public function addChildFrom(array $subfield) : self {
     if (isset($subfield[0]) && isset($subfield[1]))
-        return $this->addChild($subfield[0], $subfield[1]);
+      return $this->addChild($subfield[0], $subfield[1]);
+
+    return $this;
   }
 
 
-- 
GitLab