Newer
Older
diosmosis
a validé
<?php
/**
* Piwik - free/libre analytics platform
diosmosis
a validé
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
use Piwik\Date;
Thomas Steur
a validé
use Piwik\Tests\Framework\Fixture;
diosmosis
a validé
/**
* 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
diosmosis
a validé
{
Benaka Moorthi
a validé
public $dateTime = '2010-03-05 11:22:33';
public $idSite = 1;
diosmosis
a validé
public function setUp()
{
$this->setUpWebsitesAndGoals();
$this->trackVisits();
diosmosis
a validé
}
diosmosis
a validé
public function tearDown()
{
// empty
diosmosis
a validé
}
diosmosis
a validé
private function setUpWebsitesAndGoals()
{
diosmosis
a validé
if (!self::siteCreated($idSite = 1)) {
self::createWebsite($this->dateTime);
}
diosmosis
a validé
}
private function trackVisits()
{
$dateTime = $this->dateTime;
$idSite = $this->idSite;
diosmosis
a validé
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());
diosmosis
a validé
$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);
diosmosis
a validé
self::checkResponse($t->doTrackPageView('title'));
}
}
}
$t = self::getTracker($idSite, Date::factory($dateTime)->addHour(24)->getDatetime());
diosmosis
a validé
$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'));
Benaka Moorthi
a validé
$t = self::getTracker($idSite, Date::factory($dateTime)->addHour(24)->getDatetime());
$t->setUrl('http://example.org/page1.html');
self::checkResponse($t->doTrackPageView('title'));
diosmosis
a validé
}