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:
authorStefan Giehl <stefan@matomo.org>2022-05-17 11:46:52 +0300
committerGitHub <noreply@github.com>2022-05-17 11:46:52 +0300
commit0acc68778bcb18931b1f74f3374e85832fe2fee1 (patch)
tree2cea1cbcb79f63d393ab9cb74fffaf7751131719 /tests/PHPUnit
parentf4915657a65088de22bdfa2c380d08f634136061 (diff)
MultiSites: move getAllWithGroups method from Controller to API (#19180)
* MultiSites: move getAllWithGroups method from Controller to API * update test files * updates expected UI files * mark method as not compatible with multiple periods
Diffstat (limited to 'tests/PHPUnit')
-rw-r--r--tests/PHPUnit/System/BackwardsCompatibility1XTest.php73
-rw-r--r--tests/PHPUnit/System/expected/test_ImportLogs__MultiSites.getAllWithGroups_month.xml14
-rw-r--r--tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__MultiSites.getAllWithGroups_day.xml14
-rw-r--r--tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_day.xml6
-rw-r--r--tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_week.xml6
-rw-r--r--tests/PHPUnit/System/expected/test_noVisit__MultiSites.getAllWithGroups_day.xml14
6 files changed, 93 insertions, 34 deletions
diff --git a/tests/PHPUnit/System/BackwardsCompatibility1XTest.php b/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
index a8b5b4ebda..a76f9150fc 100644
--- a/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
+++ b/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
@@ -1,10 +1,12 @@
<?php
+
/**
* Matomo - 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\System;
use Piwik\Common;
@@ -45,7 +47,7 @@ class BackwardsCompatibility1XTest extends SystemTestCase
}
// truncate log tables so old data won't be re-archived
- foreach (array('log_visit', 'log_link_visit_action', 'log_conversion', 'log_conversion_item') as $table) {
+ foreach (['log_visit', 'log_link_visit_action', 'log_conversion', 'log_conversion_item'] as $table) {
Db::query("TRUNCATE TABLE " . Common::prefixTable($table));
}
@@ -83,7 +85,7 @@ class BackwardsCompatibility1XTest extends SystemTestCase
// note: not sure why I have to manually activate plugin in order for `./console tests:run BackwardsCompatibility1XTest` to work
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('DevicesDetection');
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
}
$this->runApiTests($api, $params);
@@ -134,14 +136,14 @@ class BackwardsCompatibility1XTest extends SystemTestCase
'avg_page_load_time',
];
- $defaultOptions = array(
+ $defaultOptions = [
'idSite' => $idSite,
'date' => $dateTime,
'disableArchiving' => true,
- 'otherRequestParameters' => array(
+ 'otherRequestParameters' => [
// when changing this, might also need to change the same line in OneVisitorTwoVisitsTest.php
'hideColumns' => 'nb_users,sum_bandwidth,nb_hits_with_bandwidth,min_bandwidth,max_bandwidth',
- ),
+ ],
'xmlFieldsToRemove' => array_merge([
'entry_sum_visit_length',
'sum_visit_length',
@@ -149,7 +151,7 @@ class BackwardsCompatibility1XTest extends SystemTestCase
'interactionPosition',
'pageviewPosition',
], $performanceMetrics),
- );
+ ];
/**
* When Piwik\Tests\System\BackwardsCompatibility1XTest is failing,
@@ -157,7 +159,7 @@ class BackwardsCompatibility1XTest extends SystemTestCase
* sometimes for a given API method that fails to generate the same output as OneVisitorTwoVisits does,
* we need to add the API below which will cause the fixtures for this API to be created in processed/
*/
- $reportsToCompareSeparately = array(
+ $reportsToCompareSeparately = [
// the label column is not the first column here
'MultiSites.getAll',
@@ -179,9 +181,9 @@ class BackwardsCompatibility1XTest extends SystemTestCase
'Tour.getLevel',
'Tour.getChallenges'
- );
+ ];
- $apiNotToCall = array(
+ $apiNotToCall = [
// in the SQL dump, a referrer is named referer.com, but now in OneVisitorTwoVisits it is referrer.com
'Referrers',
@@ -230,7 +232,10 @@ class BackwardsCompatibility1XTest extends SystemTestCase
// did not exist before Matomo 4
'PagePerformance.get',
- );
+
+ // Did not exist before Matomo 4.11.
+ 'MultiSites.getAllWithGroups'
+ ];
if (!Manager::getInstance()->isPluginActivated('CustomVariables')) {
// includes some columns that are not available when CustomVariables plugin is not available
@@ -243,53 +248,53 @@ class BackwardsCompatibility1XTest extends SystemTestCase
$allReportsOptions['compareAgainst'] = 'OneVisitorTwoVisits';
$allReportsOptions['apiNotToCall'] = $apiNotToCall;
- return array(
- array('all', $allReportsOptions),
+ return [
+ ['all', $allReportsOptions],
- array('VisitFrequency.get', array('idSite' => $idSite, 'date' => '2012-03-03', 'setDateLastN' => true,
- 'disableArchiving' => true, 'testSuffix' => '_multipleDates')),
+ ['VisitFrequency.get', ['idSite' => $idSite, 'date' => '2012-03-03', 'setDateLastN' => true,
+ 'disableArchiving' => true, 'testSuffix' => '_multipleDates']],
- array('VisitFrequency.get', array('idSite' => $idSite, 'date' => $dateTime,
- 'periods' => array('day', 'week', 'month', 'year'),
- 'disableArchiving' => false)),
+ ['VisitFrequency.get', ['idSite' => $idSite, 'date' => $dateTime,
+ 'periods' => ['day', 'week', 'month', 'year'],
+ 'disableArchiving' => false]],
- array('VisitFrequency.get', array('idSite' => $idSite, 'date' => '2012-03-06,2012-12-31',
- 'periods' => array('range'), 'disableArchiving' => true)),
+ ['VisitFrequency.get', ['idSite' => $idSite, 'date' => '2012-03-06,2012-12-31',
+ 'periods' => ['range'], 'disableArchiving' => true]],
- array('Actions.getPageUrls', array('idSite' => $idSite, 'date' => '2012-03-06,2012-12-31',
- 'otherRequestParameters' => array('expanded' => '1'),
+ ['Actions.getPageUrls', ['idSite' => $idSite, 'date' => '2012-03-06,2012-12-31',
+ 'otherRequestParameters' => ['expanded' => '1'],
'xmlFieldsToRemove' => $performanceMetrics,
'testSuffix' => '_expanded',
- 'periods' => array('range'), 'disableArchiving' => true)),
+ 'periods' => ['range'], 'disableArchiving' => true]],
- array('Actions.getPageUrls', array('idSite' => $idSite, 'date' => '2012-03-06,2012-12-31',
- 'otherRequestParameters' => array('flat' => '1'),
+ ['Actions.getPageUrls', ['idSite' => $idSite, 'date' => '2012-03-06,2012-12-31',
+ 'otherRequestParameters' => ['flat' => '1'],
'xmlFieldsToRemove' => $performanceMetrics,
'testSuffix' => '_flat',
- 'periods' => array('range'), 'disableArchiving' => true)),
+ 'periods' => ['range'], 'disableArchiving' => true]],
- array('Actions.getPageUrls', array('idSite' => $idSite, 'date' => '2012-03-06',
- 'otherRequestParameters' => array('idSubtable' => '30'),
+ ['Actions.getPageUrls', ['idSite' => $idSite, 'date' => '2012-03-06',
+ 'otherRequestParameters' => ['idSubtable' => '30'],
'xmlFieldsToRemove' => $performanceMetrics,
'testSuffix' => '_subtable',
- 'periods' => array('day'), 'disableArchiving' => true)),
+ 'periods' => ['day'], 'disableArchiving' => true]],
- array('VisitFrequency.get', array('idSite' => $idSite, 'date' => '2012-03-03,2012-12-12', 'periods' => array('month'),
- 'testSuffix' => '_multipleOldNew', 'disableArchiving' => true)),
- array($reportsToCompareSeparately, $defaultOptions),
- );
+ ['VisitFrequency.get', ['idSite' => $idSite, 'date' => '2012-03-03,2012-12-12', 'periods' => ['month'],
+ 'testSuffix' => '_multipleOldNew', 'disableArchiving' => true]],
+ [$reportsToCompareSeparately, $defaultOptions],
+ ];
}
public function provideContainerConfig()
{
- return array(
+ return [
'Piwik\Config' => \DI\decorate(function ($previous) {
$general = $previous->General;
$general['action_title_category_delimiter'] = "/";
$previous->General = $general;
return $previous;
}),
- );
+ ];
}
}
diff --git a/tests/PHPUnit/System/expected/test_ImportLogs__MultiSites.getAllWithGroups_month.xml b/tests/PHPUnit/System/expected/test_ImportLogs__MultiSites.getAllWithGroups_month.xml
new file mode 100644
index 0000000000..a6c1fa023c
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_ImportLogs__MultiSites.getAllWithGroups_month.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <numSites>3</numSites>
+ <totals>
+ <nb_pageviews>51</nb_pageviews>
+ <nb_visits>47</nb_visits>
+ <nb_actions>57</nb_actions>
+ <revenue>195</revenue>
+ <nb_visits_lastdate>0</nb_visits_lastdate>
+ </totals>
+ <lastDate>2012-07-09</lastDate>
+ <sites>
+ </sites>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__MultiSites.getAllWithGroups_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__MultiSites.getAllWithGroups_day.xml
new file mode 100644
index 0000000000..f95fe08380
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits__MultiSites.getAllWithGroups_day.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <numSites>3</numSites>
+ <totals>
+ <nb_pageviews>4</nb_pageviews>
+ <nb_visits>2</nb_visits>
+ <nb_actions>8</nb_actions>
+ <revenue>43</revenue>
+ <nb_visits_lastdate>0</nb_visits_lastdate>
+ </totals>
+ <lastDate>2010-03-05</lastDate>
+ <sites>
+ </sites>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_day.xml b/tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_day.xml
new file mode 100644
index 0000000000..f76ae70b1c
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_day.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <error message="Multiple periods are not supported
+
+ --&gt; To temporarily debug this error further, set const PIWIK_PRINT_ERROR_BACKTRACE=true; in index.php" />
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_week.xml b/tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_week.xml
new file mode 100644
index 0000000000..f76ae70b1c
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_noVisit_PeriodIsLast__MultiSites.getAllWithGroups_week.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <error message="Multiple periods are not supported
+
+ --&gt; To temporarily debug this error further, set const PIWIK_PRINT_ERROR_BACKTRACE=true; in index.php" />
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_noVisit__MultiSites.getAllWithGroups_day.xml b/tests/PHPUnit/System/expected/test_noVisit__MultiSites.getAllWithGroups_day.xml
new file mode 100644
index 0000000000..71a06b5133
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_noVisit__MultiSites.getAllWithGroups_day.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <numSites>1</numSites>
+ <totals>
+ <nb_pageviews>0</nb_pageviews>
+ <nb_visits>0</nb_visits>
+ <nb_actions>0</nb_actions>
+ <revenue>0</revenue>
+ <nb_visits_lastdate>0</nb_visits_lastdate>
+ </totals>
+ <lastDate>2009-01-03</lastDate>
+ <sites>
+ </sites>
+</result> \ No newline at end of file