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
63
64
65
66
67
68
69
70
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Fixtures;
use Piwik\Date;
use Piwik\Tests\Framework\Fixture;
/**
* Adds one site and tracks 13 visits all with custom variables and referrer URLs
* w/ sub-dirs (ie, /path/to/page/has/many/dirs.htm).
*/
class ManyVisitsWithSubDirReferrersAndCustomVars extends Fixture
{
public $dateTime = '2010-03-05 11:22:33';
public $idSite = 1;
public function setUp()
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
}
public function tearDown()
{
// empty
}
private function setUpWebsitesAndGoals()
{
if (!self::siteCreated($idSite = 1)) {
self::createWebsite($this->dateTime);
}
}
private function trackVisits()
{
$dateTime = $this->dateTime;
$idSite = $this->idSite;
for ($referrerSite = 1; $referrerSite < 4; $referrerSite++) {
for ($referrerPage = 1; $referrerPage < 3; $referrerPage++) {
$offset = $referrerSite * 3 + $referrerPage;
$t = self::getTracker($idSite, Date::factory($dateTime)->addHour($offset)->getDatetime());
$t->setUrlReferrer('http://www.referrer' . $referrerSite . '.com/sub/dir/page' . $referrerPage . '.html');
$t->setCustomVariable(1, 'CustomVarVisit', 'CustomVarValue' . $referrerPage, 'visit');
for ($page = 0; $page < 3; $page++) {
$t->setUrl('http://example.org/dir' . $referrerSite . '/sub/dir/page' . $page . '.html');
$t->setCustomVariable(1, 'CustomVarPage', 'CustomVarValue' . $page, 'page');
$t->setGenerationTime($referrerPage * $referrerSite * ($page + 1) * 100);
self::checkResponse($t->doTrackPageView('title'));
}
}
}
$t = self::getTracker($idSite, Date::factory($dateTime)->addHour(24)->getDatetime());
$t->setCustomVariable(1, 'CustomVarVisit', 'CustomVarValue1', 'visit');
$t->setUrl('http://example.org/sub/dir/dir1/page1.html');
$t->setCustomVariable(1, 'CustomVarPage', 'CustomVarValue1', 'page');
self::checkResponse($t->doTrackPageView('title'));
$t = self::getTracker($idSite, Date::factory($dateTime)->addHour(24)->getDatetime());
$t->setUrl('http://example.org/page1.html');
self::checkResponse($t->doTrackPageView('title'));
}
}
|