blob: 2a2a90946987595d6670a9c0b61a1bba8a88215a (
plain)
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
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
use Piwik\Plugins\Goals\API;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\BenchmarkTestCase;
/**
* Reusable fixture. Adds 20,000 sites and tracks one pageview for each on one day.
*/
class Piwik_Test_Fixture_ManyThousandSitesOneVisitEach
{
public $date = '2010-01-01';
public $period = 'day';
public $siteCount = 20000;
public $idSite = 'all';
public function setUp(): void
{
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');
}
}
}
|