From 473b288ac309a23cffa614b3f99018692c43229d Mon Sep 17 00:00:00 2001
From: Thomas Steur <thomas.steur@googlemail.com>
Date: Thu, 13 Mar 2014 22:02:44 +0100
Subject: [PATCH] fix test, the testcase was in the wrong test file

---
 plugins/CoreUpdater/UpdateCommunication.php     | 17 ++++++++++++-----
 .../UpdateCommunicationTest.php                 |  1 -
 .../CoreUpdater/UpdateCommunicationTest.php     |  1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/plugins/CoreUpdater/UpdateCommunication.php b/plugins/CoreUpdater/UpdateCommunication.php
index 28269d743a..5b4253f8f3 100644
--- a/plugins/CoreUpdater/UpdateCommunication.php
+++ b/plugins/CoreUpdater/UpdateCommunication.php
@@ -58,10 +58,6 @@ class UpdateCommunication
     {
         $latestVersion = $this->getLatestVersion();
 
-        if (!$this->isVersionLike($latestVersion)) {
-            return;
-        }
-
         $host = SettingsPiwik::getPiwikUrl();
 
         $subject  = Piwik::translate('CoreUpdater_NotificationSubjectAvailableCoreUpdate', $latestVersion);
@@ -109,7 +105,18 @@ class UpdateCommunication
     {
         UpdateCheck::check();
 
-        return UpdateCheck::isNewestVersionAvailable();
+        $hasUpdate = UpdateCheck::isNewestVersionAvailable();
+
+        if (!$hasUpdate) {
+            return false;
+        }
+
+        $latestVersion = self::getLatestVersion();
+        if (!$this->isVersionLike($latestVersion)) {
+            return false;
+        }
+
+        return $hasUpdate;
     }
 
     private function hasNotificationAlreadyReceived()
diff --git a/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php b/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php
index 206f121779..4b2dcec99a 100644
--- a/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php
+++ b/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php
@@ -92,7 +92,6 @@ class Plugins_CorePluginsAdmin_UpdateCommunicationTest extends DatabaseTestCase
         return array(
             array('33.0.0', '33.0.0', $this->never(), '33.0.0'), // shouldNotSend_IfAlreadyNotified
             array('31.0.0', '33.0.0', $this->never(), '33.0.0'), // shouldNotSend_IfAlreadyNotifiedAboutLaterRelease
-            array('3333.3333.3333-beta10', '31.0.0', $this->never(), '31.0.0'),  // shouldNotSend_IfLatestVersionIsNotVersionLike,
             array('33.0.0', false,    $this->once(), '33.0.0'),  // shouldSend_IfUpdateAvailableAndNeverSentAnyBefore
             array('33.0.0', '31.0.0', $this->once(), '33.0.0'),  // shouldSend_IfUpdateAvailable,
         );
diff --git a/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php b/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php
index c7cf5aa3a2..109f80c022 100644
--- a/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php
+++ b/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php
@@ -58,6 +58,7 @@ class Plugins_CoreUpdater_UpdateCommunicationTest extends DatabaseTestCase
             array(Version::VERSION, false, $this->never(), false), // shouldNotSend_IfNoUpdateAvailable
             array('33.0.0', '33.0.0', $this->never(), '33.0.0'),   // shouldNotSend_IfAlreadyNotified
             array('31.0.0', '33.0.0', $this->never(), '33.0.0'),   // shouldNotSend_IfAlreadyNotifiedAboutLaterRelease
+            array('3333.3333.3333-beta10', '31.0.0', $this->never(), '31.0.0'),  // shouldNotSend_IfLatestVersionIsNotVersionLike,
             array('33.0.0', false,    $this->once(), '33.0.0'),    // shouldSend_IfUpdateAvailableAndNeverSentAnyBefore
             array('33.0.0', '31.0.0', $this->once(), '33.0.0'),    // shouldSend_IfUpdateAvailable
         );
-- 
GitLab