From 5fe115a5277db84df6f1a18bf63224366746a943 Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Tue, 26 May 2015 10:12:16 +1200 Subject: [PATCH] Add integration test for tracking Download and Outlink with fragment --- core/Tracker/Action.php | 5 +++-- tests/PHPUnit/Integration/TrackerTest.php | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php index ca11a5d526..0b88aed213 100644 --- a/core/Tracker/Action.php +++ b/core/Tracker/Action.php @@ -208,8 +208,9 @@ abstract class Action protected function setActionUrlWithoutExcludingParameters($url) { - $this->rawActionUrl = PageUrl::getUrlIfLookValid($url); - $this->actionUrl = PageUrl::getUrlIfLookValid($url); + $url = PageUrl::getUrlIfLookValid($url); + $this->rawActionUrl = $url; + $this->actionUrl = $url; } abstract protected function getActionsToLookup(); diff --git a/tests/PHPUnit/Integration/TrackerTest.php b/tests/PHPUnit/Integration/TrackerTest.php index 4daddc0d09..f440cf2e3f 100644 --- a/tests/PHPUnit/Integration/TrackerTest.php +++ b/tests/PHPUnit/Integration/TrackerTest.php @@ -59,9 +59,6 @@ class TrackerTest extends IntegrationTestCase { parent::setUp(); - GlobalSettingsProvider::unsetSingletonInstance(); - Config::unsetInstance(); - Fixture::createWebsite('2014-01-01 00:00:00'); $this->tracker = new TestTracker(); @@ -253,6 +250,22 @@ class TrackerTest extends IntegrationTestCase $this->assertActionEquals('example.com', 2); } + public function test_trackRequest_shouldTrackOutlinkWithFragment() + { + $request = $this->buildRequest(array('idsite' => 1, 'link' => 'http://example.com/outlink#fragment-here', 'rec' => 1)); + $this->tracker->trackRequest($request); + + $this->assertActionEquals('http://example.com/outlink#fragment-here', 1); + } + + public function test_trackRequest_shouldTrackDownloadWithFragment() + { + $request = $this->buildRequest(array('idsite' => 1, 'download' => 'http://example.com/file.zip#fragment-here&pk_campaign=Campaign param accepted here', 'rec' => 1)); + $this->tracker->trackRequest($request); + + $this->assertActionEquals('http://example.com/file.zip#fragment-here&pk_campaign=Campaign param accepted here', 1); + } + public function test_main_shouldReturnEmptyPiwikResponse_IfNoRequestsAreGiven() { $requestSet = $this->getEmptyRequestSet(); -- GitLab