Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKate Butler <kate@innocraft.com>2019-04-24 03:08:50 +0300
committerThomas Steur <tsteur@users.noreply.github.com>2019-04-24 03:08:50 +0300
commit79ae22abc5fbd8595c1bf53bdb7402f184c09de3 (patch)
tree77657e17d3be7242ba7886e5d44d911e6c20c06e /tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
parent7dffd74ccc615c086173c8f6789a2b5033bf53da (diff)
Permit segmenting by order ID (#14316)
* Ability to segment by ecommerce order ID * Auto-complete for ecommerce orderId dimension * New data fixture for testing auto-suggest of order IDs * Fix API test expected files to match new fixture * Add new expected file for order ID segment API test * Revert Order metric name back to previous value * Fix unit test
Diffstat (limited to 'tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php')
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php211
1 files changed, 115 insertions, 96 deletions
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
index 275f72a62d..39f5129cdd 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
@@ -117,109 +117,128 @@ class ManyVisitsWithGeoIP extends Fixture
$t->enableBulkTracking();
}
$t->setTokenAuth(self::getTokenAuth());
- for ($i = 0; $i != $visitorCount; ++$i) {
- // NOTE: floor() is so some visits share the same visit ID
- $t->setVisitorId( substr(md5(floor($i / 2) + $calledCounter * 1000), 0, $t::LENGTH_VISITOR_ID));
-
- $userAgent = null;
- if ($setIp) {
- $userAgent = current($this->userAgents);
-
- $t->setIp(current($this->ips));
- $t->setUserAgent($userAgent);
- next($this->userAgents);
- next($this->ips);
- } else {
- $t->setIp("1.2.4.$i");
- }
-
- // first visit
- $date = Date::factory($dateTime)->addDay($i);
- $t->setForceVisitDateTime($date->getDatetime());
- $t->setUrl("http://piwik.net/grue/lair");
- $t->setCustomVariable(1, 'Cvar 1 name', 'Cvar1 value is ' .$i , 'visit');
- $t->setCustomVariable(5, 'Cvar 5 name', 'Cvar5 value is ' .$i , 'visit');
- $t->setCustomVariable(2, 'Cvar 2 PAGE name', 'Cvar2 PAGE value is ' .$i, 'page');
- $t->setCustomVariable(5, 'Cvar 5 PAGE name', 'Cvar5 PAGE value is ' .$i, 'page');
-
- $r = $t->doTrackPageView('It\'s <script> pitch black...');
- if (!$doBulk) {
- self::checkResponse($r);
- }
-
- // second visit
- if ($userAgent) {
- $t->setUserAgent($userAgent); // unset in doTrack...
- }
-
- $date = $date->addHour(1);
- $t->setForceVisitDateTime($date->getDatetime());
- $t->setUrl("http://piwik.net/space/quest/iv");
-
- // Manually record some data
- $t->setDebugStringAppend(
- '&_idts='. $date->subDay(100)->getTimestampUTC(). // first visit timestamp
- '&_ects='. $date->subDay(50)->getTimestampUTC(). // Timestamp ecommerce
- '&_viewts='. $date->subDay(10)->getTimestampUTC(). // Last visit timestamp
- '&_idvc=5' // Visit count
- );
- $r = $t->doTrackPageView("Space Quest XII");
-
- if (!$doBulk) {
- self::checkResponse($r);
- }
-
- if ($userAgent) {
- $t->setUserAgent($userAgent); // unset in doTrack...
- }
-
- // Track site search (for AutoSuggestAPI test)
- // Only for half visitors so they don't all have a "site search" as last action and some of them have a standard page view as last action
- $date = $date->addHour(0.1);
- $t->setForceVisitDateTime($date->getDatetime());
- if( ($i % 2) == 0) {
- $r = $t->doTrackSiteSearch('Bring on the party', 'CAT');
- }
-
- if (!$doBulk) {
- self::checkResponse($r);
- }
-
- $date = $date->addHour(0.2);
- $t->setForceVisitDateTime($date->getDatetime());
- $r = $t->doTrackGoal($this->idGoal2);
- if (!$doBulk) {
- self::checkResponse($r);
- }
-
- $date = $date->addHour(0.05);
- $t->setForceVisitDateTime($date->getDatetime());
- $t->doTrackAction('http://example.org/path/file' . $i . '.zip', "download" );
- if (!$doBulk) {
- self::checkResponse($r);
- }
-
- $date = $date->addHour(0.05);
- $t->setForceVisitDateTime($date->getDatetime());
- $r = $t->doTrackAction('http://example-outlink.org/' . $i . '.html', "link" );
- if (!$doBulk) {
- self::checkResponse($r);
- }
-
- $date = $date->addHour(0.05);
- $t->setForceVisitDateTime($date->getDatetime());
- $r = $t->doTrackEvent('Cat' . $i, 'Action' . $i, 'Name' . $i, 345.678 + $i );
-
- if (!$doBulk) {
- self::checkResponse($r);
- }
+ for ($i = 0; $i != $visitorCount; ++$i) {
+ $this->trackVisit($t, $calledCounter, $i, $doBulk, array('setIp' => $setIp));
}
+
if ($doBulk) {
self::checkBulkTrackingResponse($t->doBulkTrack());
}
}
+ /**
+ * Insert a new visit into the database.
+ * @param \PiwikTracker $t The tracker to record the visits on
+ * @param int $fixtureCounter Number of times this fixture has been run
+ * @param int $visitorCounter Visitor counter within this execution of the fixture
+ * @param boolean $doBulk Should this visit be left for bulk insert later, or processed now?
+ * @param array $params Other params as required to set up the visit
+ */
+ protected function trackVisit(\PiwikTracker $t, $fixtureCounter, $visitorCounter, $doBulk, array $params)
+ {
+ $setIp = isset($params['setIp']) && $params['setIp'];
+
+ // NOTE: floor() is so some visits share the same visit ID
+ $t->setVisitorId( substr(md5(floor($visitorCounter / 2) + $fixtureCounter * 1000), 0, $t::LENGTH_VISITOR_ID));
+
+ $userAgent = null;
+ if ($setIp) {
+ $userAgent = current($this->userAgents);
+
+ $t->setIp(current($this->ips));
+ $t->setUserAgent($userAgent);
+ next($this->userAgents);
+ next($this->ips);
+ } else {
+ $t->setIp("1.2.4.$visitorCounter");
+ }
+
+ // first visit
+ $date = Date::factory($this->dateTime)->addDay($visitorCounter);
+ $t->setForceVisitDateTime($date->getDatetime());
+ $t->setUrl("http://piwik.net/grue/lair");
+ $t->setCustomVariable(1, 'Cvar 1 name', 'Cvar1 value is ' .$visitorCounter , 'visit');
+ $t->setCustomVariable(5, 'Cvar 5 name', 'Cvar5 value is ' .$visitorCounter , 'visit');
+ $t->setCustomVariable(2, 'Cvar 2 PAGE name', 'Cvar2 PAGE value is ' .$visitorCounter, 'page');
+ $t->setCustomVariable(5, 'Cvar 5 PAGE name', 'Cvar5 PAGE value is ' .$visitorCounter, 'page');
+
+ $r = $t->doTrackPageView('It\'s <script> pitch black...');
+ if (!$doBulk) {
+ self::checkResponse($r);
+ }
+
+ // second visit
+ if ($userAgent) {
+ $t->setUserAgent($userAgent); // unset in doTrack...
+ }
+
+ $date = $date->addHour(1);
+ $t->setForceVisitDateTime($date->getDatetime());
+ $t->setUrl("http://piwik.net/space/quest/iv");
+
+ // Manually record some data
+ $t->setDebugStringAppend(
+ '&_idts='. $date->subDay(100)->getTimestampUTC(). // first visit timestamp
+ '&_ects='. $date->subDay(50)->getTimestampUTC(). // Timestamp ecommerce
+ '&_viewts='. $date->subDay(10)->getTimestampUTC(). // Last visit timestamp
+ '&_idvc=5' // Visit count
+ );
+ $r = $t->doTrackPageView("Space Quest XII");
+
+ if (!$doBulk) {
+ self::checkResponse($r);
+ }
+
+ if ($userAgent) {
+ $t->setUserAgent($userAgent); // unset in doTrack...
+ }
+
+ // Track site search (for AutoSuggestAPI test)
+ // Only for half visitors so they don't all have a "site search" as last action and some of them have a standard page view as last action
+ $date = $date->addHour(0.1);
+ $t->setForceVisitDateTime($date->getDatetime());
+ if( ($visitorCounter % 2) == 0) {
+ $r = $t->doTrackSiteSearch('Bring on the party', 'CAT');
+ }
+
+ if (!$doBulk) {
+ self::checkResponse($r);
+ }
+
+ $date = $date->addHour(0.2);
+ $t->setForceVisitDateTime($date->getDatetime());
+ $r = $t->doTrackGoal($this->idGoal2);
+ if (!$doBulk) {
+ self::checkResponse($r);
+ }
+
+ $date = $date->addHour(0.05);
+ $t->setForceVisitDateTime($date->getDatetime());
+ $t->doTrackAction('http://example.org/path/file' . $visitorCounter . '.zip', "download" );
+ if (!$doBulk) {
+ self::checkResponse($r);
+ }
+
+ $date = $date->addHour(0.05);
+ $t->setForceVisitDateTime($date->getDatetime());
+ $r = $t->doTrackAction('http://example-outlink.org/' . $visitorCounter . '.html', "link" );
+ if (!$doBulk) {
+ self::checkResponse($r);
+ }
+
+ $date = $date->addHour(0.05);
+ $t->setForceVisitDateTime($date->getDatetime());
+ $r = $t->doTrackEvent('Cat' . $visitorCounter,
+ 'Action' . $visitorCounter,
+ 'Name' . $visitorCounter,
+ 345.678 + $visitorCounter
+ );
+ if (!$doBulk) {
+ self::checkResponse($r);
+ }
+ }
+
private function trackOtherVisits()
{
$dateTime = $this->dateTime;