From c227bfd6f06cff2aa5d34259eebbaf3a1e545c5e Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Tue, 20 Nov 2018 17:15:25 +0100
Subject: [PATCH] hotline#81316 fix test

---
 cosmogramme/php/classes/classe_notice_integration.php         | 4 ++--
 library/Class/Notice/SerialArticles.php                       | 3 ++-
 .../library/Class/Cosmogramme/Integration/PhaseNoticeTest.php | 4 ++++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php
index 9ae4bd84284..c4110b69820 100644
--- a/cosmogramme/php/classes/classe_notice_integration.php
+++ b/cosmogramme/php/classes/classe_notice_integration.php
@@ -939,10 +939,10 @@ class notice_integration {
                                   'Updated' => dateDuJour(0),
                                   'Quality' => $this->qualite_bib]);
 
-    if (!$serial = Class_Notice_SerialArticles::updateOrInsert($instance))
+    if (null === ($serial = Class_Notice_SerialArticles::updateOrInsert($instance)))
       return;
 
-    $this->statut = $serial->isNew()
+    $this->statut = $serial
       ? static::RECORD_INSERT
       : static::RECORD_RENEW;
   }
diff --git a/library/Class/Notice/SerialArticles.php b/library/Class/Notice/SerialArticles.php
index 2b6823ab1a5..7b668bfe181 100644
--- a/library/Class/Notice/SerialArticles.php
+++ b/library/Class/Notice/SerialArticles.php
@@ -37,8 +37,9 @@ class NoticeSerialArticlesLoader extends Storm_Model_Loader {
                                     'qualite' => $instance->getQuality()]);
 
     $serial->updateAttributes($update_columns);
+    $is_new = $serial->isNew();
     $serial->save();
-    return $serial;
+    return $is_new;
   }
 
 
diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php
index 21215f0a43d..2808f39cb81 100644
--- a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php
+++ b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php
@@ -184,6 +184,10 @@ class PhaseNoticeImportFullTest extends PhaseNoticeImportTestCase {
     $this->assertEquals(110, $this->_phase->getCount(Class_Cosmogramme_Integration_Phase::RECORD_INSERT));
   }
 
+  /** @test */
+  public function phaseCounterShouldNotContainsRecordsRenew() {
+    $this->assertEquals(0, $this->_phase->getCount(Class_Cosmogramme_Integration_Phase::RECORD_RENEW));
+  }
 
   /** @test */
   public function phaseCounterShouldContain17RecordsRejected() {
-- 
GitLab