From 181ad8ffb018885b81c373101799bb34e9dbaebb Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Mon, 25 Sep 2017 14:54:29 +0200
Subject: [PATCH] hotline #65042 fix tests failures

---
 .../cosmo/controllers/IntegrationControllerTest.php       | 8 ++++----
 library/Class/Cosmogramme/Generator.php                   | 7 +++----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php
index e977750460a..6ebfd9c32d6 100644
--- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php
+++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php
@@ -348,7 +348,7 @@ class Cosmo_IntegrationControllerGenerateActionNanookPostTest
 
   protected function _setupExistingDeletedBib() {
     $lib = $this->fixture('Class_IntBib',
-                          ['id_bib' => 6,
+                          ['id' => 6,
                            'nom' => 'Existing deleted',
                            'nom_court' => 'Deleted',
                            'qualite' => 5,
@@ -362,7 +362,6 @@ class Cosmo_IntegrationControllerGenerateActionNanookPostTest
                     'profil' => 103,
                     'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                     'nom_fichier' => 'library/site6/reservations.txt']);
-
   }
 
 
@@ -423,12 +422,13 @@ class Cosmo_IntegrationControllerGenerateActionNanookPostTest
   public function library1IntegrationShouldBeCreated() {
     $this->assertNotNull($bib = Class_IntBib::findFirstBy(['id_bib' => 20,
                                                            'nom' => 'library1',
-                                                           'nom_court' => 'library1',
+                                                           'nom_court' => 'library',
                                                            'qualite' => 5,
                                                            'sigb' => Class_IntBib::SIGB_NANOOK,
                                                            'planif_mode' => 'r',
                                                            'planif_jours' => '1111111',
-                                                           'comm_sigb' => Class_IntBib::COM_NANOOK]));
+                                                           'comm_sigb' => Class_IntBib::COM_NANOOK
+                                                           ]));
     return $bib;
   }
 
diff --git a/library/Class/Cosmogramme/Generator.php b/library/Class/Cosmogramme/Generator.php
index 4f2e291ba8f..02d02bdf3ad 100644
--- a/library/Class/Cosmogramme/Generator.php
+++ b/library/Class/Cosmogramme/Generator.php
@@ -161,16 +161,14 @@ class Class_Cosmogramme_Generator {
     $bib->updateAttributes(['id_site' => $elem[0],
                             'libelle' => trim($elem[1]),
                             'id_zone' => 1,
-                            'visibilite' => Class_Bib::V_DATA])
-        ->save();
+                            'visibilite' => Class_Bib::V_DATA]);
 
-    if (!$int_bib = Class_IntBib::findFirstBy(['id_bib' => $bib->getIdSite()])) {
+    if (!$int_bib = Class_IntBib::findFirstBy(['id_bib' => $bib->getIdSite()]))
       $int_bib = Class_IntBib::newInstance(['id_bib' => $bib->getIdSite(),
                                             'qualite' => 5,
                                             'sigb' => $this->_params['type_sigb'],
                                             'planif_mode' => 'r',
                                             'planif_jours' => '1111111']);
-    }
 
     $int_bib->updateAttributes(['nom' => $bib->getLibelle(),
                                 'nom_court' => $bib->getLibelle()]);
@@ -178,6 +176,7 @@ class Class_Cosmogramme_Generator {
     $this->_generateNewLibrary($int_bib);
 
 		$int_bib->save();
+    $bib->save();
 
     return '<tr><td class="blank">Site n° '. $bib->getIdSite() . '</td><td class="blank">'. $bib->getLibelle() . '</td></tr>';
   }
-- 
GitLab