1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Reusable fixture. Tracks twelve thousand page views over a year for one site.
*/
class Piwik_Test_Fixture_OneSiteTwelveThousandVisitsOneYear
{
public $date = '2010-01-01';
public $period = 'year';
public $idSite = 1;
public $idGoal1 = 1;
public $idGoal2 = 2;
public function setUp()
{
// add one site
Test_Piwik_BaseFixture::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) {
$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);
}
}
}
}
}
|