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:
authorThomas Steur <thomas.steur@googlemail.com>2014-08-09 19:02:04 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-08-09 19:02:04 +0400
commit3b962d95d59ee68215d10a088cf08935521dd54a (patch)
tree81f004fc3aab329f124ae7aef2fa5c31627f2037 /plugins
parenta2f3959a8c3f730d871fbe0e3cc437a64ac98494 (diff)
fixes #5951 throw an exception in getRowEvolution if a report is request that does not have a dimension
Diffstat (limited to 'plugins')
-rw-r--r--plugins/API/RowEvolution.php4
-rw-r--r--plugins/API/tests/RowEvolutionTest.php44
2 files changed, 48 insertions, 0 deletions
diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php
index 84bc431c47..7a5290c44f 100644
--- a/plugins/API/RowEvolution.php
+++ b/plugins/API/RowEvolution.php
@@ -331,6 +331,10 @@ class RowEvolution
$metrics = $metrics + $reportMetadata['processedMetrics'];
}
+ if (empty($reportMetadata['dimension'])) {
+ throw new Exception(sprintf('Reports like %s.%s which do not have a dimension are not supported by row evolution', $apiModule, $apiAction));
+ }
+
$dimension = $reportMetadata['dimension'];
return compact('metrics', 'dimension');
diff --git a/plugins/API/tests/RowEvolutionTest.php b/plugins/API/tests/RowEvolutionTest.php
new file mode 100644
index 0000000000..b341efd91a
--- /dev/null
+++ b/plugins/API/tests/RowEvolutionTest.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\API\tests;
+use Piwik\Plugins\API\RowEvolution;
+use Piwik\Tests\Fixture;
+
+/**
+ * @group API
+ * @group RowEvolutionTest
+ * @group Database
+ */
+class RowEvolutionTest extends \DatabaseTestCase
+{
+
+ public function setUp()
+ {
+ parent::setUp();
+ Fixture::createWebsite('2014-01-01 00:00:00');
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Reports like VisitsSummary.get which do not have a dimension are not supported by row evolution
+ */
+ public function test_getRowEvolution_shouldTriggerAnException_IfReportHasNoDimension()
+ {
+ $rowEvolution = new RowEvolution();
+ $rowEvolution->getRowEvolution(1, 'day', 'last7', 'VisitsSummary', 'get');
+ }
+
+ public function test_getRowEvolution_shouldNotTriggerAnException_IfReportHasADimension()
+ {
+ $rowEvolution = new RowEvolution();
+ $table = $rowEvolution->getRowEvolution(1, 'day', 'last7', 'Actions', 'getPageUrls');
+ $this->assertNotEmpty($table);
+ }
+
+}