public function setUp()
 {
     $sitesManager = Piwik_SitesManager_API::getInstance();
     $goals = Piwik_Goals_API::getInstance();
     // add one thousand sites
     $allIdSites = array();
     for ($i = 0; $i < 1000; ++$i) {
         $allIdSites[] = IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}");
     }
     // add goals to 500 sites
     $idGoals = array();
     foreach ($allIdSites as $idSite) {
         if ($idSite % 2 == 0) {
             $idGoal1 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
             $idGoal2 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains');
             $idGoals[$idSite] = array($idGoal1, $idGoal2);
         } else {
             $idGoals[$idSite] = array();
         }
     }
     $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 = Piwik_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($this->idSite);
                 $ip = "157.5.6." . ($visitor + 1);
                 $t->setIp($ip);
                 $t->setForceVisitDateTime($visitTime);
                 foreach ($urls as $url => $title) {
                     $t->setUrl($url);
                     $t->doTrackPageView($title);
                 }
             }
         }
     }
 }
 public function setUp()
 {
     // add one site
     IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
     // add two goals
     $goals = Piwik_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 = Piwik_Date::factory($this->date);
     for ($month = 0; $month != 12; ++$month) {
         for ($day = 0; $day != 25; ++$day) {
             $hour = $time * 31 / 60.0;
             $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->setForceVisitDateTime($visitTime);
             foreach ($urls as $url => $title) {
                 $t->setUrl($url);
                 $t->doTrackPageView($title);
             }
         }
     }
 }
Пример #3
0
 public function setUp()
 {
     // add one site
     IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
     // add two goals
     $goals = Piwik_Goals_API::getInstance();
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
 }