public function setUp() { // add one site Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/"); // add two goals $goals = API::getInstance(); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5); $goals->addGoal($this->idSite, 'all', 'url', 'thing2', 'contains'); $start = Date::factory($this->date); $dates = array(); for ($day = 0; $day != 31; ++$day) { $dates[] = $start->addDay($day); } $t = BenchmarkTestCase::getLocalTracker($this->idSite); $actionNum = 0; foreach ($dates as $date) { for ($visitNum = 0; $visitNum != 1000; ++$visitNum) { if ($visitNum % 2 == 0) { $url = "http://whatever.com/{$actionNum}/0/1/2/3/4/5/6/7/8/9"; $referrerUrl = "http://google.com/?q={$actionNum}"; } else { $url = "http://whatever.com/thing2/{$actionNum}/0/1/2/3/4/5/6/7/8/9"; $referrerUrl = "http://"; } $title = "A page title / {$actionNum} / 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 /9"; $t->setNewVisitorId(); $t->setForceVisitDateTime($date); $t->setUrl($url); $t->setUrlReferrer($referrerUrl); Fixture::checkResponse($t->doTrackPageView($title)); ++$actionNum; } } }
public function setUp() { // add one thousand sites $allIdSites = array(); for ($i = 0; $i < 1000; ++$i) { $allIdSites[] = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}"); } $urls = array(); for ($i = 0; $i != 3; ++$i) { $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1); $title = "page view " . ($i - 1) . " / " . ($i + 1); $urls[$url] = $title; } $visitTimes = array(); $date = Date::factory($this->date); for ($i = 0; $i != 4; ++$i) { $visitTimes[] = $date->addHour($i)->getDatetime(); } // add 12000 visits (3 visitors with 4 visits each for each site) w/ 3 pageviews each on one day foreach ($visitTimes as $visitTime) { foreach ($allIdSites as $idSite) { for ($visitor = 0; $visitor != 3; ++$visitor) { $t = BenchmarkTestCase::getLocalTracker($idSite); $ip = "157.5.6." . ($visitor + 1); $t->setIp($ip); $t->setNewVisitorId(); $t->setForceVisitDateTime($visitTime); foreach ($urls as $url => $title) { $t->setUrl($url); $t->doTrackPageView($title); } } } } }
public function setUp() { for ($i = 0; $i != $this->siteCount; ++$i) { $idSite = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}", $siteUrl = "http://site{$i}.com/"); API::getInstance()->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5); } // track one visit for each site $t = BenchmarkTestCase::getLocalTracker(1); $t->setForceVisitDateTime(Date::factory($this->date)->addHour(6)); for ($idSite = 1; $idSite < $this->siteCount + 1; ++$idSite) { $ip = "157.5.6.4"; $t->setIp($ip); $t->setNewVisitorId(); $t->setIdSite($idSite); $t->setUrl("http://site" . ($idSite - 1) . ".com/page.html"); $t->doTrackPageView('page title'); } }
public function setUp() { // add one site Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/"); // add two goals $goals = API::getInstance(); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains'); $urls = array(); for ($i = 0; $i != 3; ++$i) { $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1); $title = "page view " . ($i - 1) . " / " . ($i + 1); $urls[$url] = $title; } $visitTimes = array(); $date = Date::factory($this->date); for ($month = 0; $month != 12; ++$month) { for ($day = 0; $day != 25; ++$day) { $visitTimes[] = $date->addPeriod($month, 'MONTH')->addDay($day)->getDatetime(); } } // add 12,000 visits (1 visit a day from 40 visitors for 25 days of every month) w/ 3 pageviews each foreach ($visitTimes as $visitTime) { for ($visitor = 0; $visitor != 40; ++$visitor) { $t = BenchmarkTestCase::getLocalTracker($this->idSite); $ip = "157.5.6." . ($visitor + 1); $t->setIp($ip); $t->setNewVisitorId(); $t->setForceVisitDateTime($visitTime); foreach ($urls as $url => $title) { $t->setUrl($url); $t->doTrackPageView($title); } } } }
/** * @group Core */ public function testIsDefined() { // setup the access layer $pseudoMockAccess = new FakeAccess(); FakeAccess::$superUser = true; Access::setSingletonInstance($pseudoMockAccess); \Piwik\Translate::loadEnglishTranslation(); Fixture::createWebsite('2009-01-04 00:11:42', true); $_GET['idSite'] = 1; WidgetsList::_reset(); WidgetsList::add('Actions', 'Pages', 'Actions', 'getPageUrls'); $this->assertTrue(WidgetsList::isDefined('Actions', 'getPageUrls')); $this->assertFalse(WidgetsList::isDefined('Actions', 'inValiD')); }
public function test_request_shouldBeAbleToRenderARegularPageInPiwik() { Fixture::createWebsite('2014-01-01 00:00:00'); $urls = array($this->completeUrl('/?module=Widgetize&idSite=1&period=day&date=today')); $response = $this->cliMulti->request($urls); $message = "Response was: " . substr(implode("\n\n", $response), 0, 4000); $this->assertTrue(false !== strpos($response[0], '<meta name="generator" content="Piwik - Open Source Web Analytics"/>'), $message); $this->assertTrue(false !== strpos($response[0], 'Widgetize the full dashboard') . $message); }
protected static function _addLogData() { // tracks visits on the following days: // - 2012-01-09 // - 2012-01-14 // - 2012-01-19 // - 2012-01-24 <--- everything before this date is to be purged // - 2012-01-29 // - 2012-02-03 // - 2012-02-08 // - 2012-02-13 // - 2012-02-18 // - 2012-02-23 // - 2012-02-28 // 6 visits in feb, 5 in jan // following actions are created: // - 'First page view' // - 'Second page view' // - 'SKU2' // - 'Canon SLR' // - 'Electronics & Cameras' // - for every visit (11 visits total): // - http://whatever.com/_{$daysSinceLastVisit} // - http://whatever.com/42/{$daysSinceLastVisit} $start = Date::factory(self::$dateTime); self::$idSite = Fixture::createWebsite('2012-01-01', $ecommerce = 1); $idGoal = APIGoals::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains'); $t = Fixture::getTracker(self::$idSite, $start, $defaultInit = true); $t->enableBulkTracking(); $t->setTokenAuth(Fixture::getTokenAuth()); for ($daysAgo = self::$daysAgoStart; $daysAgo >= 0; $daysAgo -= 5) { $dateTime = $start->subDay($daysAgo)->toString(); $t->setForceVisitDateTime($dateTime); $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)'); // use $daysAgo to make sure new actions are created for every day and aren't used again. // when deleting visits, some of these actions will no longer be referenced in the DB. $t->setUrl("http://whatever.com/_{$daysAgo}"); $t->doTrackPageView('First page view'); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.05)); $t->setUrl("http://whatever.com/42/{$daysAgo}"); $t->doTrackPageView('Second page view'); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1)); $t->setUrl("http://whatever.com/event"); $t->doTrackEvent('Event action', 'event cat', 'daysAgo=' . $daysAgo, 1000); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)); $t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR', $category = 'Electronics & Cameras', $price = 1500, $quantity = 1); $t->doTrackEcommerceOrder($orderId = '937nsjusu ' . $dateTime, $grandTotal = 1111.11, $subTotal = 1000, $tax = 111, $shipping = 0.11, $discount = 666); } Fixture::checkBulkTrackingResponse($t->doBulkTrack()); }
public function setUp() { // add one site Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/"); // add two goals $goals = API::getInstance(); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains'); }
public function setUp() { parent::setUp(); \Piwik\Piwik::setUserHasSuperUserAccess(true); Fixture::createWebsite('2014-02-04'); }