Skip to content

Commit

Permalink
Refs matomo-org#472 Adding events in other tests to make sure events …
Browse files Browse the repository at this point in the history
…don't regress
  • Loading branch information
mattab committed Oct 23, 2013
1 parent abcb066 commit b194c90
Show file tree
Hide file tree
Showing 40 changed files with 126 additions and 100 deletions.
4 changes: 4 additions & 0 deletions plugins/Actions/ArchivingHelper.php
Expand Up @@ -356,6 +356,10 @@ protected static function getActionRow($actionName, $actionType, $urlPrefix = nu
/* @var DataTable $currentTable */
$currentTable =& $actionsTablesByType[$actionType];

if(is_null($currentTable)) {
throw new \Exception("Action table for type '$actionType' was not found during Actions archiving.");
}

// check for ranking query cut-off
if ($actionName == DataTable::LABEL_SUMMARY_ROW) {
$summaryRow = $currentTable->getRowFromId(DataTable::ID_SUMMARY_ROW);
Expand Down
5 changes: 5 additions & 0 deletions tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php
Expand Up @@ -52,6 +52,11 @@ private function trackVisits()
$t->setGenerationTime(153);
self::checkResponse($t->doTrackPageView('incredible parent title! <>,; / subtitle <>,;'));

$t->setUrl('http://example.org/dir/file.php?foo=bar&foo2=bar2');
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.31)->getDatetime());
$t->setGenerationTime(153);
self::checkResponse($t->doTrackEvent('Category', 'Action', 'Name', 11111));

$t->setUrl('http://example.org/dir2/file.php?foo=bar&foo2=bar');
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.4)->getDatetime());
$t->setGenerationTime(1233);
Expand Down
17 changes: 10 additions & 7 deletions tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php
Expand Up @@ -48,8 +48,11 @@ private function trackVisits()
$this->trackPageView($tracker, 0.3, 'the/third_page.html?foo=bar');
$this->trackPageView($tracker, 0.4, 'page/one.html');
$this->trackPageView($tracker, 0.5, 'the/third_page.html?foo=bar');
$this->trackPageView($tracker, 0.5, 'the/third_page.html?foo=bar');
$this->trackPageView($tracker, 0.6, 'page/one.html');
$this->trackPageView($tracker, 0.6, 'page/one.html');
$this->trackPageView($tracker, 0.7, 'the/third_page.html?foo=baz#anchor1');
$this->trackPageView($tracker, 0.7, 'the/third_page.html?foo=baz#anchor1');
$this->trackPageView($tracker, 0.8, 'page/one.html');
$this->trackPageView($tracker, 0.9, 'page/one.html');
$this->trackPageView($tracker, 1.0, 'the/third_page.html?foo=baz#anchor2');
Expand Down Expand Up @@ -85,15 +88,13 @@ private function trackVisits()
// before & after
$tracker->setIp('156.5.3.6');
$tracker->setNewVisitorId();
$this->trackPageView($tracker, 0, 'page/search.html#q=mykwd', $this->dateTime, $pageViewType = 'site-search',
$searchKeyword = 'mykwd', $searchCategory = 'mysearchcat');
$this->trackPageView($tracker, 0, 'page/search.html#q=mykwd', $this->dateTime, $pageViewType = 'site-search', $searchKeyword = 'mykwd', $searchCategory = 'mysearchcat');
$this->trackPageView($tracker, 0.1, 'page/one.html');
$this->trackPageView($tracker, 0.2, 'page/search.html#q=anotherkwd', $this->dateTime,
$pageViewType = 'site-search', $searchKeyword = 'anotherkwd',
$searchCategory = 'mysearchcat');
$this->trackPageView($tracker, 0.2, 'page/search.html#q=anotherkwd', $this->dateTime, $pageViewType = 'site-search', $searchKeyword = 'anotherkwd', $searchCategory = 'mysearchcat');
$this->trackPageView($tracker, 0.25, 'page/one.html');
$this->trackPageView($tracker, 0.3, 'to/outlink/page.html', $this->dateTime, $pageViewType = 'outlink');
$this->trackPageView($tracker, 0.35, 'page/one.html');
$this->trackPageView($tracker, 0.11, 'page/search.html#q=thirdkwd', $this->dateTime, $pageViewType = 'event', 'Song name here', 'Music');
$this->trackPageView($tracker, 0.4, '', $this->dateTime, $pageViewType = 'download');
$this->trackPageView($tracker, 0.45, 'page/one.html');
$this->trackPageView($tracker, 0.5, '', $this->dateTime, $pageViewType = 'download');
Expand All @@ -104,9 +105,9 @@ private function trackVisits()
$laterDate = Date::factory($this->dateTime)->addDay(8)->getDatetime();
$tracker->setIp('156.5.3.7');
$tracker->setNewVisitorId();
$this->trackPageView($tracker, 0, 'page/search.html#q=thirdkwd', $laterDate, $pageViewType = 'site-search',
$searchKeyword = 'thirdkwd', $searchCategory = 'mysearchcat');
$this->trackPageView($tracker, 0, 'page/search.html#q=thirdkwd', $laterDate, $pageViewType = 'site-search', $searchKeyword = 'thirdkwd', $searchCategory = 'mysearchcat');
$this->trackPageView($tracker, 0.1, 'page/one.html', $laterDate);
$this->trackPageView($tracker, 0.11, 'page/search.html#q=thirdkwd', $laterDate, $pageViewType = 'event', 'Song name here', 'Music');
$this->trackPageView($tracker, 0.15, 'to/another/outlink.html', $laterDate, $pageViewType = 'outlink');
$this->trackPageView($tracker, 0.2, 'page/one.html', $laterDate);
$this->trackPageView($tracker, 0.25, '', $laterDate, $pageViewType = 'download');
Expand Down Expand Up @@ -143,6 +144,8 @@ private function trackPageView($visit, $timeOffset, $path, $dateTime = null, $pa
self::assertTrue($visit->doTrackAction($downloadUrl, 'download'));
} else if ($pageViewType == 'site-search') {
self::assertTrue($visit->doTrackSiteSearch($searchKeyword, $searchCategory, $this->prefixCounter));
} else if ($pageViewType == 'event') {
self::assertTrue($visit->doTrackEvent($searchCategory, "event name", $searchKeyword, $this->prefixCounter));
}
}
}
Expand Up @@ -70,6 +70,9 @@ protected function recordVisitorsSite1()
$visitor->setUrl('http://example.org/index.htm?random=PAGEVIEW, NOT SEARCH&mykwd=&IS_FOLLOWING_SEARCH ONCE');
self::checkResponse($visitor->doTrackPageView('This is a pageview, not a Search - IS_FOLLOWING_SEARCH ONCE'));

$visitor->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(0.24)->getDatetime());
self::checkResponse($visitor->doTrackEvent("Event CAT", "Event ACTION", "Event NAME", $count = 3.33));

$visitor->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(0.25)->getDatetime());
$visitor->setUrl('http://example.org/index.htm?standard=query&but=also#hash&q=' . urlencode('Search 1'));
self::checkResponse($visitor->doTrackPageView('Site Search results - URL Fragment'));
Expand Down Expand Up @@ -113,6 +116,9 @@ protected function recordVisitorsSite1()
$visitor->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(24.42)->getDatetime());
self::checkResponse($visitor->doTrackSiteSearch("Keyword - Tracking API", "Category", $count = 5));

$visitor->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(24.425)->getDatetime());
self::checkResponse($visitor->doTrackEvent("Event CAT", "Event ACTION", "Event NAME", $count));

$visitor->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(24.43)->getDatetime());
self::checkResponse($visitor->doTrackSiteSearch("No Result Keyword!", "Bad No Result Category :(", $count = 0));

Expand Down
Expand Up @@ -4,11 +4,11 @@
<label>dir</label>
<nb_visits>2</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>720</sum_time_spent>
<sum_time_spent>684</sum_time_spent>
<nb_hits_with_time_generation>2</nb_hits_with_time_generation>
<min_time_generation>0.123</min_time_generation>
<max_time_generation>0.153</max_time_generation>
<avg_time_on_page>360</avg_time_on_page>
<avg_time_on_page>342</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<avg_time_generation>0.138</avg_time_generation>
Expand Down
Expand Up @@ -5,11 +5,11 @@
<label>dir</label>
<nb_visits>2</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>720</sum_time_spent>
<sum_time_spent>684</sum_time_spent>
<nb_hits_with_time_generation>2</nb_hits_with_time_generation>
<min_time_generation>0.123</min_time_generation>
<max_time_generation>0.153</max_time_generation>
<avg_time_on_page>360</avg_time_on_page>
<avg_time_on_page>342</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<avg_time_generation>0.138</avg_time_generation>
Expand Down
Expand Up @@ -4,8 +4,8 @@
<label>&lt;&gt;&amp;\&quot;the pdo extension is required for this adapter but the extension is not loaded</label>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_visits>1</nb_visits>
<nb_actions>6</nb_actions>
<max_actions>6</max_actions>
<nb_actions>7</nb_actions>
<max_actions>7</max_actions>
<sum_visit_length>1441</sum_visit_length>
<bounce_count>0</bounce_count>
<nb_visits_converted>0</nb_visits_converted>
Expand Down
Expand Up @@ -11,7 +11,7 @@
<max_time_generation>0.523</max_time_generation>
<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>6</entry_nb_actions>
<entry_nb_actions>7</entry_nb_actions>
<entry_sum_visit_length>1441</entry_sum_visit_length>
<entry_bounce_count>0</entry_bounce_count>
<avg_time_on_page>720</avg_time_on_page>
Expand Down
Expand Up @@ -5,11 +5,11 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>1</nb_hits>
<sum_time_spent>360</sum_time_spent>
<sum_time_spent>324</sum_time_spent>
<nb_hits_with_time_generation>1</nb_hits_with_time_generation>
<min_time_generation>0.153</min_time_generation>
<max_time_generation>0.153</max_time_generation>
<avg_time_on_page>360</avg_time_on_page>
<avg_time_on_page>324</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<avg_time_generation>0.153</avg_time_generation>
Expand Down
Expand Up @@ -11,7 +11,7 @@
<max_time_generation>1.233</max_time_generation>
<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>6</entry_nb_actions>
<entry_nb_actions>7</entry_nb_actions>
<entry_sum_visit_length>1441</entry_sum_visit_length>
<entry_bounce_count>0</entry_bounce_count>
<avg_time_on_page>1080</avg_time_on_page>
Expand Down
Expand Up @@ -63,7 +63,7 @@
<label> This is a pageview, not a Search - IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<avg_time_on_page>00:04:12</avg_time_on_page>
<avg_time_on_page>00:03:36</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<avg_time_generation>0s</avg_time_generation>
Expand Down
Expand Up @@ -63,7 +63,7 @@
<label> This is a pageview, not a Search - IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<avg_time_on_page>00:04:12</avg_time_on_page>
<avg_time_on_page>00:03:36</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<avg_time_generation>0s</avg_time_generation>
Expand Down
Expand Up @@ -63,7 +63,7 @@
<label>/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<avg_time_on_page>00:04:12</avg_time_on_page>
<avg_time_on_page>00:03:36</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<avg_time_generation>0s</avg_time_generation>
Expand Down
Expand Up @@ -63,7 +63,7 @@
<label>/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<avg_time_on_page>00:04:12</avg_time_on_page>
<avg_time_on_page>00:03:36</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<avg_time_generation>0s</avg_time_generation>
Expand Down
Expand Up @@ -18,9 +18,9 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -17,10 +17,10 @@
<label> This is a pageview, not a Search - IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -30,9 +30,9 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -29,10 +29,10 @@
<label> This is a pageview, not a Search - IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -19,9 +19,9 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<url>http://example.org/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</url>
Expand Down
Expand Up @@ -18,10 +18,10 @@
<label>/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<url>http://example.org/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</url>
Expand Down
Expand Up @@ -32,9 +32,9 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<url>http://example.org/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</url>
Expand Down
Expand Up @@ -31,10 +31,10 @@
<label>/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<url>http://example.org/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</url>
Expand Down
Expand Up @@ -50,9 +50,9 @@
<label>Keyword - Tracking API</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>72</sum_time_spent>
<sum_time_spent>54</sum_time_spent>
<nb_pages_per_search>2</nb_pages_per_search>
<avg_time_on_page>72</avg_time_on_page>
<avg_time_on_page>54</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -48,9 +48,9 @@
<label>Keyword - Tracking API</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>72</sum_time_spent>
<sum_time_spent>54</sum_time_spent>
<nb_pages_per_search>2</nb_pages_per_search>
<avg_time_on_page>72</avg_time_on_page>
<avg_time_on_page>54</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -16,9 +16,9 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -15,10 +15,10 @@
<label> This is a pageview, not a Search - IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -28,9 +28,9 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -27,10 +27,10 @@
<label> This is a pageview, not a Search - IS_FOLLOWING_SEARCH ONCE</label>
<nb_visits>1</nb_visits>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
</row>
Expand Down
Expand Up @@ -17,9 +17,9 @@
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits>
<sum_time_spent>252</sum_time_spent>
<sum_time_spent>216</sum_time_spent>
<nb_hits_following_search>1</nb_hits_following_search>
<avg_time_on_page>252</avg_time_on_page>
<avg_time_on_page>216</avg_time_on_page>
<bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate>
<url>http://example.org/index.htm?random=PAGEVIEW, NOT SEARCH&amp;mykwd=&amp;IS_FOLLOWING_SEARCH ONCE</url>
Expand Down

0 comments on commit b194c90

Please sign in to comment.