From 4b79d4171a4c9179591156feda167b91cd18c49a Mon Sep 17 00:00:00 2001 From: diosmosis <benaka@piwik.pro> Date: Tue, 22 Sep 2015 01:22:13 -0700 Subject: [PATCH] Fixing integration tests. --- .../tests/Integration/UpdateCommunicationTest.php | 8 +++++--- .../Test/Integration/UpdateCommunicationTest.php | 15 +++++++++------ tests/PHPUnit/Framework/Fixture.php | 11 ++++++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/plugins/CorePluginsAdmin/tests/Integration/UpdateCommunicationTest.php b/plugins/CorePluginsAdmin/tests/Integration/UpdateCommunicationTest.php index dff84a7fee..bbfd7af081 100644 --- a/plugins/CorePluginsAdmin/tests/Integration/UpdateCommunicationTest.php +++ b/plugins/CorePluginsAdmin/tests/Integration/UpdateCommunicationTest.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\CorePluginsAdmin\tests\Integration; use Piwik\Config; use Piwik\Option; use Piwik\Plugins\CorePluginsAdmin\UpdateCommunication; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; /** @@ -121,7 +122,8 @@ class UpdateCommunicationTest extends IntegrationTestCase public function test_sendNotificationIfUpdatesAvailable_ShouldSendCorrectText() { $subject = 'CoreUpdater_NotificationSubjectAvailablePluginUpdate'; - $message = 'ScheduledReports_EmailHello + $rootUrl = Fixture::getTestRootUrl(); + $message = "ScheduledReports_EmailHello CoreUpdater_ThereIsNewPluginVersionAvailableForUpdate @@ -130,9 +132,9 @@ CoreUpdater_ThereIsNewPluginVersionAvailableForUpdate * MyTest3 31.0.0 CoreUpdater_NotificationClickToUpdatePlugins -http://localhost/tests/PHPUnit/proxy/index.php?module=CorePluginsAdmin&action=plugins +{$rootUrl}index.php?module=CorePluginsAdmin&action=plugins -Installation_HappyAnalysing'; +Installation_HappyAnalysing"; $mock = $this->getCommunicationMockHavingManyUpdates(); diff --git a/plugins/CoreUpdater/Test/Integration/UpdateCommunicationTest.php b/plugins/CoreUpdater/Test/Integration/UpdateCommunicationTest.php index 156138d770..d43e11ebf4 100644 --- a/plugins/CoreUpdater/Test/Integration/UpdateCommunicationTest.php +++ b/plugins/CoreUpdater/Test/Integration/UpdateCommunicationTest.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\CoreUpdater\Test; use Piwik\Config; use Piwik\Option; use Piwik\Plugins\CoreUpdater\UpdateCommunication; +use Piwik\Tests\Framework\Fixture; use Piwik\UpdateCheck; use Piwik\Version; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; @@ -67,33 +68,35 @@ class UpdateCommunicationTest extends IntegrationTestCase public function test_sendNotifications_shouldSentCorrectEmail() { - $message = 'ScheduledReports_EmailHello + $rootUrl = Fixture::getTestRootUrl(); + $message = "ScheduledReports_EmailHello CoreUpdater_ThereIsNewVersionAvailableForUpdate CoreUpdater_YouCanUpgradeAutomaticallyOrDownloadPackage -http://localhost/tests/PHPUnit/proxy/index.php?module=CoreUpdater&action=newVersionAvailable +{$rootUrl}index.php?module=CoreUpdater&action=newVersionAvailable CoreUpdater_ViewVersionChangelog http://piwik.org/changelog/piwik-33-0-0/ CoreUpdater_FeedbackRequest -http://piwik.org/contact/'; +http://piwik.org/contact/"; $this->assertEmailForVersion('33.0.0', $message); } public function test_sendNotifications_shouldNotIncludeChangelogIfNotMajorVersionUpdate() { - $message = 'ScheduledReports_EmailHello + $rootUrl = Fixture::getTestRootUrl(); + $message = "ScheduledReports_EmailHello CoreUpdater_ThereIsNewVersionAvailableForUpdate CoreUpdater_YouCanUpgradeAutomaticallyOrDownloadPackage -http://localhost/tests/PHPUnit/proxy/index.php?module=CoreUpdater&action=newVersionAvailable +{$rootUrl}index.php?module=CoreUpdater&action=newVersionAvailable CoreUpdater_FeedbackRequest -http://piwik.org/contact/'; +http://piwik.org/contact/"; $this->assertEmailForVersion('33.0.0-b1', $message); } diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index da83196a5e..f0a2f1978f 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -141,6 +141,11 @@ class Fixture extends \PHPUnit_Framework_Assert return 'python'; } + public static function getTestRootUrl() + { + return self::getRootUrl() . 'tests/PHPUnit/proxy/'; + } + public function loginAsSuperUser() { /** @var Auth $auth */ @@ -277,7 +282,7 @@ class Fixture extends \PHPUnit_Framework_Assert APILanguageManager::getInstance()->setLanguageForUser('superUserLogin', 'en'); } - SettingsPiwik::overwritePiwikUrl(self::getRootUrl() . 'tests/PHPUnit/proxy/'); + SettingsPiwik::overwritePiwikUrl(self::getTestRootUrl()); if ($setupEnvironmentOnly) { return; @@ -513,7 +518,7 @@ class Fixture extends \PHPUnit_Framework_Assert */ public static function getTrackerUrl() { - return self::getRootUrl() . 'tests/PHPUnit/proxy/piwik.php'; + return self::getTestRootUrl() . 'piwik.php'; } /** @@ -820,7 +825,7 @@ class Fixture extends \PHPUnit_Framework_Assert $cmd = $python . ' "' . PIWIK_INCLUDE_PATH . '/misc/log-analytics/import_logs.py" ' # script loc . '-ddd ' // debug - . '--url="' . self::getRootUrl() . 'tests/PHPUnit/proxy/" ' # proxy so that piwik uses test config files + . '--url="' . self::getTestRootUrl() . '" ' # proxy so that piwik uses test config files ; foreach ($options as $name => $values) { -- GitLab