diff options
author | Stefan Giehl <stefan@matomo.org> | 2022-05-17 11:46:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 11:46:52 +0300 |
commit | 0acc68778bcb18931b1f74f3374e85832fe2fee1 (patch) | |
tree | 2cea1cbcb79f63d393ab9cb74fffaf7751131719 /tests | |
parent | f4915657a65088de22bdfa2c380d08f634136061 (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')
7 files changed, 95 insertions, 36 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 + + --> 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 + + --> 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 diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_api_listing.png b/tests/UI/expected-screenshots/UIIntegrationTest_api_listing.png index 73316afc15..faaed3b33f 100644 --- a/tests/UI/expected-screenshots/UIIntegrationTest_api_listing.png +++ b/tests/UI/expected-screenshots/UIIntegrationTest_api_listing.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3bb33ee911ee997ba39c10764f85c005fcc3a0e5670b959ae34900c925f9968d -size 5019088 +oid sha256:43da6112ff8af49a08be6924df7d4f600febdbff940f605459f82e0e97c1a00b +size 5030169 |