diff options
author | sgiehl <stefangiehl@gmail.com> | 2012-07-30 00:59:29 +0400 |
---|---|---|
committer | sgiehl <stefangiehl@gmail.com> | 2012-07-30 00:59:29 +0400 |
commit | a69fe73945a7a1883f2f8e4ad442db4477409379 (patch) | |
tree | a133a23b9151aeece72011ef71fe5d1b501ea359 /tests/PHPUnit | |
parent | d6b3e2d1ce0bcad2247205721a0c0bdc7351d38e (diff) |
refs #3227 more and more integration tests migrated :)
git-svn-id: http://dev.piwik.org/svn/trunk@6590 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'tests/PHPUnit')
6 files changed, 604 insertions, 0 deletions
diff --git a/tests/PHPUnit/Core/Unzip/empty.zip b/tests/PHPUnit/Core/Unzip/empty.zip new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/PHPUnit/Core/Unzip/empty.zip diff --git a/tests/PHPUnit/Integration/RowEvolutionTest.php b/tests/PHPUnit/Integration/RowEvolutionTest.php new file mode 100755 index 0000000000..0d074643ba --- /dev/null +++ b/tests/PHPUnit/Integration/RowEvolutionTest.php @@ -0,0 +1,139 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * @version $Id$ + */ + +/** + * Tests the method API.getRowEvolution + */ +class Test_Piwik_Integration_RowEvolution extends IntegrationTestCase +{ + protected static $today = '2010-03-06 11:22:33'; + protected static $idSite = 1; + protected static $keywords = array( + 'free > proprietary', // BUG! testing a keyword containing > + 'peace "," not war', // testing a keyword containing , + 'justice )(&^#%$ NOT corruption!', + ); + + /** + * @dataProvider getApiForTesting + * @group Integration + * @group RowEvolution + */ + public function testApi($api, $params) + { + $this->runApiTests($api, $params); + } + + public function getApiForTesting() + { + $return = array(); + + $config = array( + 'testSuffix' => '_referrer1', + 'idSite' => self::$idSite, + 'date' => self::$today, + 'otherRequestParameters' => array( + 'date' => '2010-02-06,2010-03-06', + 'period' => 'day', + 'apiModule' => 'Referers', + 'apiAction' => 'getWebsites', + 'label' => 'www.referrer2.com', + 'expanded' => 0 + ) + ); + + $return[] = array('API.getRowEvolution', $config); + + // Websites, hierarchical + $config['testSuffix'] = '_referrer2'; + $referrerLabel = urlencode('www.referrer0.com') . '>' . urlencode('theReferrerPage1.html'); + $config['otherRequestParameters']['label'] = $referrerLabel; + $return[] = array('API.getRowEvolution', $config); + + // Websites, multiple labels including one hierarchical + $config['testSuffix'] = '_referrerMulti1'; + $referrerLabel = urlencode($referrerLabel) . ',' . urlencode('www.referrer2.com'); + $config['otherRequestParameters']['label'] = $referrerLabel; + $return[] = array('API.getRowEvolution', $config); + + // Keywords, label containing > and , + $config['otherRequestParameters']['apiAction'] = 'getKeywords'; + $config['testSuffix'] = '_LabelReservedCharacters'; + $keywords = urlencode(self::$keywords[0]) . ',' . urlencode(self::$keywords[1]); + $config['otherRequestParameters']['label'] = $keywords; + $return[] = array('API.getRowEvolution', $config); + + // Keywords, hierarchical + $config['otherRequestParameters']['apiAction'] = 'getSearchEngines'; + $config['testSuffix'] = '_LabelReservedCharactersHierarchical'; + $keywords = "Google>" . urlencode(strtolower(self::$keywords[0])) + . ',Google>' . urlencode(strtolower(self::$keywords[1])) + . ',Google>' . urlencode(strtolower(self::$keywords[2])); + // Test multiple labels search engines, Google should also have a 'logo' entry + $config['otherRequestParameters']['label'] = $keywords . ",Google"; + $return[] = array('API.getRowEvolution', $config); + + // Actions > Pages titles, standard label + $config['testSuffix'] = '_pageTitles'; + $config['periods'] = array('day', 'week'); + $config['otherRequestParameters']['apiModule'] = 'Actions'; + $config['otherRequestParameters']['apiAction'] = 'getPageTitles'; + $config['otherRequestParameters']['label'] = 'incredible title 0'; + $return[] = array('API.getRowEvolution', $config); + + // Actions > Page titles, multiple labels + $config['testSuffix'] = '_pageTitlesMulti'; + $label = urlencode('incredible title 0') . ',' . urlencode('incredible title 2'); + $config['otherRequestParameters']['label'] = $label; + $return[] = array('API.getRowEvolution', $config); + + // Actions > Page URLS, hierarchical label + $config['testSuffix'] = '_pageUrls'; + $config['periods'] = array('range'); + $config['otherRequestParameters']['date'] = '2010-03-01,2010-03-06'; + $config['otherRequestParameters']['apiModule'] = 'Actions'; + $config['otherRequestParameters']['apiAction'] = 'getPageUrls'; + $config['otherRequestParameters']['label'] = 'my>dir>' . urlencode('/page3?foo=bar&baz=bar'); + $return[] = array('API.getRowEvolution', $config); + + return $return; + } + + public function getOutputPrefix() + { + return 'RowEvolution'; + } + + protected function setUpWebsitesAndGoals() + { + $this->createWebsite('2010-02-01 11:22:33'); + } + + protected function trackVisits() + { + $dateTime = self::$today; + $idSite = self::$idSite; + + for ($daysIntoPast = 30; $daysIntoPast >= 0; $daysIntoPast--) { + // Visit 1: referrer website + test page views + $visitDateTime = Piwik_Date::factory($dateTime)->subDay($daysIntoPast)->getDatetime(); + $t = $this->getTracker($idSite, $visitDateTime, $defaultInit = true); + $t->setUrlReferrer('http://www.referrer' . ($daysIntoPast % 5) . '.com/theReferrerPage' . ($daysIntoPast % 2) . '.html'); + $t->setUrl('http://example.org/my/dir/page' . ($daysIntoPast % 4) . '?foo=bar&baz=bar'); + $t->setForceVisitDateTime($visitDateTime); + $this->checkResponse($t->doTrackPageView('incredible title ' . ($daysIntoPast % 3))); + + // VISIT 2: search engine + $t->setForceVisitDateTime(Piwik_Date::factory($visitDateTime)->addHour(3)->getDatetime()); + $t->setUrlReferrer('http://google.com/search?q=' . urlencode(self::$keywords[$daysIntoPast % 3])); + $this->checkResponse($t->doTrackPageView('not an incredible title ')); + } + } +} + diff --git a/tests/PHPUnit/Integration/TrackCustomVariablesAndCampaigns_ForceUsingVisitIdNotHeuristicsTest.php b/tests/PHPUnit/Integration/TrackCustomVariablesAndCampaigns_ForceUsingVisitIdNotHeuristicsTest.php new file mode 100755 index 0000000000..c64c7acba8 --- /dev/null +++ b/tests/PHPUnit/Integration/TrackCustomVariablesAndCampaigns_ForceUsingVisitIdNotHeuristicsTest.php @@ -0,0 +1,106 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * @version $Id$ + */ + +/** + * Test tracker & API when forcing the use of visit ID instead of heuristics. Also + * tests campaign tracking. + */ +class Test_Piwik_Integration_TrackCustomVariablesAndCampaigns_ForceUsingVisitIdNotHeuristics extends IntegrationTestCase +{ + protected static $dateTime = '2009-01-04 00:11:42'; + protected static $idSite = 1; + protected static $idGoal = 1; + + /** + * @dataProvider getApiForTesting + * @group Integration + * @group TrackCustomVariablesAndCampaigns_ForceUsingVisitIdNotHeuristics + */ + public function testApi($api, $params) + { + $this->runApiTests($api, $params); + } + + public function getApiForTesting() + { + $apiToCall = array('VisitsSummary.get', 'Referers.getCampaigns', 'Referers.getWebsites'); + + return array( + // TOTAL should be: 1 visit, 1 converted goal, 1 page view + array($apiToCall, array('idSite' => self::$idSite, 'date' => self::$dateTime)) + ); + } + + public function getOutputPrefix() + { + return 'PiwikTracker_trackForceUsingVisitId_insteadOfHeuristics_alsoTestsCampaignTracking'; + } + + public function setUpWebsitesAndGoals() + { + $this->createWebsite(self::$dateTime); + Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'triggered js', 'manually', '', ''); + } + + protected function trackVisits() + { + $dateTime = self::$dateTime; + $idSite = self::$idSite; + $idGoal = self::$idGoal; + + $t = $this->getTracker($idSite, $dateTime, $defaultInit = true); + + // Record 1st page view + $t->setUrl('http://example.org/index.htm?utm_campaign=GA Campaign&piwik_kwd=Piwik kwd&utm_term=GA keyword SHOULD NOT DISPLAY#pk_campaign=NOT TRACKED!!&pk_kwd=NOT TRACKED!!'); + $this->checkResponse($t->doTrackPageView('incredible title!')); + + $visitorId = $t->getVisitorId(); + $this->assertTrue(strlen($visitorId) == 16); + + // test setting/getting the first party cookie via the PHP Tracking Client + $_COOKIE['_pk_id_1_1fff'] = 'ca0afe7b6b692ff5.1302307497.1.1302307497.1302307497'; + $_COOKIE['_pk_ref_1_1fff'] = '["YEAH","RIGHT!",1302307497,"http://referrer.example.org/page/sub?query=test&test2=test3"]'; + $_COOKIE['_pk_cvar_1_1fff'] = '{"1":["VAR 1 set, var 2 not set","yes"],"3":["var 3 set","yes!!!!"]}'; + $this->assertTrue($t->getVisitorId() == 'ca0afe7b6b692ff5'); + $this->assertTrue($t->getAttributionInfo() == $_COOKIE['_pk_ref_1_1fff']); + $this->assertTrue($t->getCustomVariable(1) == array("VAR 1 set, var 2 not set", "yes")); + $this->assertTrue($t->getCustomVariable(2) == false); + $this->assertTrue($t->getCustomVariable(3) == array("var 3 set", "yes!!!!")); + $this->assertTrue($t->getCustomVariable(4) == false); + $this->assertTrue($t->getCustomVariable(5) == false); + $this->assertTrue($t->getCustomVariable(6) == false); + $this->assertTrue($t->getCustomVariable(-1) == false); + unset($_COOKIE['_pk_id_1_1fff']); + unset($_COOKIE['_pk_ref_1_1fff']); + unset($_COOKIE['_pk_cvar_1_1fff']); + + // Create a new Tracker object, with different attributes + $t2 = $this->getTracker($idSite, $dateTime, $defaultInit = false); + + // Make sure the ID is different at first + $visitorId2 = $t2->getVisitorId(); + $this->assertTrue($visitorId != $visitorId2); + + // Then force the visitor ID + $t2->setVisitorId($visitorId); + + // And Record a Goal: The previous visit should be updated rather than a new visit Created + $t2->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.3)->getDatetime()); + $this->checkResponse($t2->doTrackGoal($idGoal, $revenue = 42.256)); + + // Yet another visitor, this time with a manual goal conversion, which should be credited to the campaign + $t3 = $this->getTracker($idSite, $dateTime); + $t3->setUrlReferrer('http://example.org/referrer'); + $t3->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(1.3)->getDatetime()); + // fake a website ref cookie, the campaign should be credited for conversion, not referrer.example.com nor example.org + $t3->DEBUG_APPEND_URL = '&_ref=http%3A%2F%2Freferrer.example.com%2Fpage%2Fsub%3Fquery%3Dtest%26test2%3Dtest3'; + $t3->setUrl('http://example.org/index.htm#pk_campaign=CREDITED TO GOAL PLEASE'); + $this->checkResponse($t3->doTrackGoal($idGoal, 42)); + } +} diff --git a/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php b/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php new file mode 100755 index 0000000000..712695ae09 --- /dev/null +++ b/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php @@ -0,0 +1,104 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * @version $Id$ + */ + +/** + * Tests API methods with goals that do and don't allow multiple + * conversions per visit. + */ +class Test_Piwik_Integration_TrackGoals_AllowMultipleConversionsPerVisit extends IntegrationTestCase +{ + protected static $dateTime = '2009-01-04 00:11:42'; + protected static $idSite = 1; + protected static $idGoal_OneConversionPerVisit = 1; + protected static $idGoal_MultipleConversionPerVisit = 2; + + /** + * @group Integration + * @group TrackGoals_AllowMultipleConversionsPerVisit + */ + public function testApi() + { + $testData = $this->getApiForTesting(); + + foreach ($testData AS $data) { + $api = $data[0]; + $params = $data[1]; + $this->runApiTests($api, $params); + } + + $idSite = self::$idSite; + + // test delete is working as expected + $goals = Piwik_Goals_API::getInstance()->getGoals($idSite); + $this->assertTrue(2 == count($goals)); + Piwik_Goals_API::getInstance()->deleteGoal($idSite, self::$idGoal_OneConversionPerVisit); + Piwik_Goals_API::getInstance()->deleteGoal($idSite, self::$idGoal_MultipleConversionPerVisit); + $goals = Piwik_Goals_API::getInstance()->getGoals($idSite); + $this->assertTrue(empty($goals)); + } + + public function getApiForTesting() + { + $apiToCall = array('VisitTime.getVisitInformationPerServerTime', 'VisitsSummary.get'); + + return array( + array($apiToCall, array('idSite' => self::$idSite, 'date' => self::$dateTime)) + ); + } + + public function getOutputPrefix() + { + return 'trackGoals_allowMultipleConversionsPerVisit'; + } + + public function setUpWebsitesAndGoals() + { + $this->createWebsite(self::$dateTime); + + // First, a goal that is only recorded once per visit + Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'triggered js ONCE', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = false); + + // Second, a goal allowing multiple conversions + Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'triggered js MULTIPLE ALLOWED', 'manually', '', '', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = true); + } + + protected function trackVisits() + { + $dateTime = self::$dateTime; + $idSite = self::$idSite; + $idGoal_OneConversionPerVisit = self::$idGoal_OneConversionPerVisit; + $idGoal_MultipleConversionPerVisit = self::$idGoal_MultipleConversionPerVisit; + + $t = $this->getTracker($idSite, $dateTime, $defaultInit = true); + + // Record 1st goal, should only have 1 conversion + $t->setUrl('http://example.org/index.htm'); + $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.3)->getDatetime()); + $this->checkResponse($t->doTrackPageView('Thank you mate')); + $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.4)->getDatetime()); + $this->checkResponse($t->doTrackGoal($idGoal_OneConversionPerVisit, $revenue = 10000000)); + + // Record 2nd goal, should record both conversions + $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.5)->getDatetime()); + $this->checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 300)); + $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.6)->getDatetime()); + $this->checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 366)); + + // Update & set to not allow multiple + $goals = Piwik_Goals_API::getInstance()->getGoals($idSite); + $goal = $goals[$idGoal_OneConversionPerVisit]; + $this->assertTrue($goal['allow_multiple'] == 0); + Piwik_Goals_API::getInstance()->updateGoal($idSite, $idGoal_OneConversionPerVisit, $goal['name'], @$goal['match_attribute'], @$goal['pattern'], @$goal['pattern_type'], @$goal['case_sensitive'], $goal['revenue'], $goal['allow_multiple'] = 1); + $this->assertTrue($goal['allow_multiple'] == 1); + + // 1st goal should Now be tracked + $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.61)->getDatetime()); + $this->checkResponse($t->doTrackGoal($idGoal_OneConversionPerVisit, $revenue = 656)); + } +} diff --git a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDaysTest.php b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDaysTest.php new file mode 100755 index 0000000000..4e2541a246 --- /dev/null +++ b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDaysTest.php @@ -0,0 +1,189 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * @version $Id$ + */ + +/** + * tests Tracker several websites, different days. + * tests API for period=day/week/month/year, requesting data for both websites, + * and requesting data for last N periods. + * Also tests a visit that spans over 2 days. + * And testing empty URL and empty Page name request + * Also testing a click on a mailto counted as outlink + * Also testing metadata API for multiple periods + */ +class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends IntegrationTestCase +{ + protected static $idSite1 = 1; + protected static $idSite2 = 2; + protected static $idGoal1 = 1; + protected static $idGoal2 = 2; + protected static $dateTime = '2010-01-03 11:22:33'; + protected static $allowConversions = false; + + /** + * @dataProvider getApiForTesting + * @group Integration + * @group TwoVisitors_TwoWebsites_DifferentDays + */ + public function testApi($api, $params) + { + $this->runApiTests($api, $params); + } + + protected function getApiToCall() + { + return array('VisitFrequency.get', + 'VisitsSummary.get', + 'Referers.getWebsites', + 'Actions.getPageUrls', + 'Actions.getPageTitles', + 'Actions.getOutlinks', + 'Actions.getPageTitle', + 'Actions.getPageUrl', + 'VisitorInterest.getNumberOfVisitsByDaysSinceLast'); + } + + public function getApiForTesting() + { + $apiToCall = $this->getApiToCall(); + $singlePeriodApi = array('VisitsSummary.get', 'Goals.get'); + + $periods = array('day', 'week', 'month', 'year'); + + $result = array( + // Request data for the last 6 periods and idSite=all + array($apiToCall, array('idSite' => 'all', 'date' => self::$dateTime, 'periods' => $periods, + 'setDateLastN' => true)), + + // Request data for the last 6 periods and idSite=1 + array($apiToCall, array('idSite' => self::$idSite1, 'date' => self::$dateTime, 'periods' => $periods, + 'setDateLastN' => true, 'testSuffix' => '_idSiteOne_')), + + // We also test a single period to check that this use case (Reports per idSite in the response) works + array($singlePeriodApi, array('idSite' => 'all', 'date' => self::$dateTime, 'periods' => array('day', 'month'), + 'setDateLastN' => false, 'testSuffix' => '_NotLastNPeriods')), + ); + + // testing metadata API for multiple periods + $apiToCall = array_diff($apiToCall, array('Actions.getPageTitle', 'Actions.getPageUrl')); + foreach ($apiToCall as $api) { + list($apiModule, $apiAction) = explode(".", $api); + + $result[] = array( + 'API.getProcessedReport', array('idSite' => self::$idSite1, 'date' => self::$dateTime, + 'periods' => array('day'), 'setDateLastN' => true, + 'apiModule' => $apiModule, 'apiAction' => $apiAction, + 'testSuffix' => '_' . $api . '_firstSite_lastN') + ); + } + + return $result; + } + + public function getOutputPrefix() + { + return 'TwoVisitors_twoWebsites_differentDays'; + } + + public function setUpWebsitesAndGoals() + { + // tests run in UTC, the Tracker in UTC + $ecommerce = self::$allowConversions ? 1 : 0; + + $this->createWebsite(self::$dateTime, $ecommerce, "Site 1"); + $this->createWebsite(self::$dateTime, 0, "Site 2"); + + if (self::$allowConversions) { + Piwik_Goals_API::getInstance()->addGoal(self::$idSite1, 'all', 'url', 'http', 'contains', false, 5); + Piwik_Goals_API::getInstance()->addGoal(self::$idSite2, 'all', 'url', 'http', 'contains'); + } + } + + protected function trackVisits() + { + $dateTime = self::$dateTime; + $idSite = self::$idSite1; + $idSite2 = self::$idSite2; + + // - + // First visitor on Idsite 1: two page views + $datetimeSpanOverTwoDays = '2010-01-03 23:55:00'; + $visitorA = $this->getTracker($idSite, $datetimeSpanOverTwoDays, $defaultInit = true); + $visitorA->setUrlReferrer('http://referer.com/page.htm?param=valuewith some spaces'); + $visitorA->setUrl('http://example.org/index.htm'); + $visitorA->DEBUG_APPEND_URL = '&_idts=' . Piwik_Date::factory($datetimeSpanOverTwoDays)->getTimestamp(); + $this->checkResponse($visitorA->doTrackPageView('first page view')); + + $visitorA->setForceVisitDateTime(Piwik_Date::factory($datetimeSpanOverTwoDays)->addHour(0.1)->getDatetime()); + // testing with empty URL and empty page title + $visitorA->setUrl(' '); + $this->checkResponse($visitorA->doTrackPageView(' ')); + + // - + // Second new visitor on Idsite 1: one page view + $visitorB = $this->getTracker($idSite, $dateTime, $defaultInit = true); + $visitorB->enableBulkTracking(); + // calc token auth by hand in test environment + $tokenAuth = md5( + Piwik_Config::getInstance()->superuser['login'] . Piwik_Config::getInstance()->superuser['password']); + $visitorB->setTokenAuth($tokenAuth); + $visitorB->setIp('100.52.156.83'); + $visitorB->setResolution(800, 300); + $visitorB->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(1)->getDatetime()); + $visitorB->setUrlReferrer(''); + $visitorB->setUserAgent('Opera/9.63 (Windows NT 5.1; U; en) Presto/2.1.1'); + $visitorB->setUrl('http://example.org/products'); + $visitorB->DEBUG_APPEND_URL = '&_idts=' . Piwik_Date::factory($dateTime)->addHour(1)->getTimestamp(); + $this->assertTrue($visitorB->doTrackPageView('first page view')); + + // - + // Second visitor again on Idsite 1: 2 page views 2 days later, 2010-01-05 + $visitorB->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(48)->getDatetime()); + // visitor_returning is set to 1 only when visit count more than 1 + // Temporary, until we implement 1st party cookies in PiwikTracker + $visitorB->DEBUG_APPEND_URL .= '&_idvc=2&_viewts=' . Piwik_Date::factory($dateTime)->getTimestamp(); + + $visitorB->setUrlReferrer('http://referer.com/Other_Page.htm'); + $visitorB->setUrl('http://example.org/index.htm'); + $this->assertTrue($visitorB->doTrackPageView('second visitor/two days later/a new visit')); + // Second page view 6 minutes later + $visitorB->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(48)->addHour(0.1)->getDatetime()); + $visitorB->setUrl('http://example.org/thankyou'); + $this->assertTrue($visitorB->doTrackPageView('second visitor/two days later/second page view')); + + // testing a strange combination causing an error in r3767 + $visitorB->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(48)->addHour(0.2)->getDatetime()); + $this->assertTrue($visitorB->doTrackAction('mailto:test@example.org', 'link')); + $visitorB->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(48)->addHour(0.25)->getDatetime()); + $this->assertTrue($visitorB->doTrackAction('mailto:test@example.org/strangelink', 'link')); + + // Actions.getPageTitle tested with this title + $visitorB->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(48)->addHour(0.25)->getDatetime()); + $this->assertTrue($visitorB->doTrackPageView('Checkout / Purchasing...')); + $this->checkResponse($visitorB->doBulkTrack()); + + // - + // First visitor on Idsite 2: one page view, with Website referer + $visitorAsite2 = $this->getTracker($idSite2, Piwik_Date::factory($dateTime)->addHour(24)->getDatetime(), $defaultInit = true); + $visitorAsite2->setUserAgent('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;)'); + $visitorAsite2->setUrlReferrer('http://only-homepage-referer.com/'); + $visitorAsite2->setUrl('http://example2.com/home'); + $visitorAsite2->DEBUG_APPEND_URL = '&_idts=' . Piwik_Date::factory($dateTime)->addHour(24)->getTimestamp(); + $this->checkResponse($visitorAsite2->doTrackPageView('Website 2 page view')); + // test with invalid URL + $visitorAsite2->setUrl('this is invalid url'); + // and an empty title + $this->checkResponse($visitorAsite2->doTrackPageView('')); + + // Returning visitor on Idsite 2 1 day later, one page view, with chinese referer +// $t2->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(48 + 10)->getDatetime()); +// $t2->setUrlReferrer('http://www.baidu.com/s?wd=%D0%C2+%CE%C5&n=2'); +// $t2->setUrl('http://example2.com/home'); +// $this->checkResponse($t2->doTrackPageView('I\'m a returning visitor...')); + } +} diff --git a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ArchivingDisabledTest.php b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ArchivingDisabledTest.php new file mode 100755 index 0000000000..1a5dd71c0b --- /dev/null +++ b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ArchivingDisabledTest.php @@ -0,0 +1,66 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * @version $Id$ + */ + +require_once dirname(__FILE__) . '/TwoVisitors_TwoWebsites_DifferentDaysTest.php'; + +/** + * TODO + */ +class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays_ArchivingDisabled extends Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays +{ + protected static $allowConversions = true; + + /** + * @group Integration + * @group TwoWebsites_DifferentDays_ArchivingDisabled + */ + public function testApi() + { + $testData = $this->getApiForTesting(); + + foreach ($testData AS $data) { + $api = $data[0]; + $params = $data[1]; + $this->runApiTests($api, $params); + } + } + + public function getApiForTesting() + { + $periods = array('day', 'week', 'month', 'year'); + + return array( + // disable archiving & check that there is no archive data + array('VisitsSummary.get', array('idSite' => 'all', + 'date' => self::$dateTime, + 'periods' => $periods, + 'disableArchiving' => true, + 'testSuffix' => '_disabledBefore')), + + // re-enable archiving & check the output + array('VisitsSummary.get', array('idSite' => 'all', + 'date' => self::$dateTime, + 'periods' => $periods, + 'disableArchiving' => false, + 'testSuffix' => '_enabled')), + + // diable archiving again & check the output + array('VisitsSummary.get', array('idSite' => 'all', + 'date' => self::$dateTime, + 'periods' => $periods, + 'disableArchiving' => true, + 'testSuffix' => '_disabledAfter')), + ); + } + + public function getOutputPrefix() + { + return 'TwoVisitors_twoWebsites_differentDays_ArchivingDisabled'; + } +} |