From dc72f59b61eddd0e66d7f123b6c897d9b1e8ff12 Mon Sep 17 00:00:00 2001
From: Laurent Laffont <llaffont@afi-sa.fr>
Date: Sat, 18 Mar 2017 14:13:50 +0100
Subject: [PATCH] hotline #57673 fix annex list after library deletion

---
 VERSIONS_HOTLINE/57673                              |  1 +
 .../cosmo/controllers/AnnexeControllerTest.php      | 13 +++++++++++++
 library/Class/CodifAnnexe.php                       |  8 ++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/57673

diff --git a/VERSIONS_HOTLINE/57673 b/VERSIONS_HOTLINE/57673
new file mode 100644
index 00000000000..58171138d3a
--- /dev/null
+++ b/VERSIONS_HOTLINE/57673
@@ -0,0 +1 @@
+ - ticket #57673 : correction d'affichage des annexes dans cosmogramme suite à la suppression d'une bibliothèque
\ No newline at end of file
diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php
index 6452cc73b3c..49621af5514 100644
--- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php
+++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php
@@ -47,6 +47,13 @@ abstract class AnnexeControllerTestCase extends CosmoControllerTestCase {
                     'code' => 'ACY01',
                     'id_origine' => 'ACY-01',
                     'id_bib' => 56]);
+
+    $this->fixture('Class_CodifAnnexe',
+                   ['id' => 120,
+                    'libelle' => 'Annex lost',
+                    'code' => 'P01',
+                    'id_origine' => 'P01',
+                    'id_bib' => 666]);
   }
 }
 
@@ -66,6 +73,12 @@ class AnnexeControllerIndexTest extends AnnexeControllerTestCase {
   }
 
 
+  /** @test */
+  public function lostAnnexShouldBeInTable() {
+    $this->assertXPathContentContains('//table//td', 'Annex lost');
+  }
+
+
   /** @test */
   public function annexeAnnecyIdOrigineShouldBeInTable() {
     $this->assertXPathContentContains('//table//td', 'ACY-01');
diff --git a/library/Class/CodifAnnexe.php b/library/Class/CodifAnnexe.php
index 710e05eae8d..90750c9dbfb 100644
--- a/library/Class/CodifAnnexe.php
+++ b/library/Class/CodifAnnexe.php
@@ -61,12 +61,16 @@ class Class_CodifAnnexe extends Storm_Model_Abstract {
 
 
   public function getMailIntBib() {
-    return $this->getIntBib()->getMail();
+    return $this->hasIntBib()
+      ? $this->getIntBib()->getMail()
+      : '';
   }
 
 
   public function getLibraryLabel() {
-    return $this->getIntBib()->getLabel();
+    return $this->hasIntBib()
+      ? $this->getIntBib()->getLabel()
+      : '';
   }
 
 
-- 
GitLab