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-10-05 15:05:47 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-10-05 15:05:47 +0400
commit5a1eab97f54b44f57356b4276b9c9df2a8eef51b (patch)
tree83864ece2806ccf6e6bb49abf3fd65de92c13ad8 /tests/PHPUnit/System/PivotByQueryParamTest.php
parent19bcd2d262343eae9d553378e4c66ce7e033b4d8 (diff)
refs #5940 put tests in correct folders, better testsuite names, some tests still fail and I cannot figure out why
Diffstat (limited to 'tests/PHPUnit/System/PivotByQueryParamTest.php')
-rw-r--r--tests/PHPUnit/System/PivotByQueryParamTest.php189
1 files changed, 189 insertions, 0 deletions
diff --git a/tests/PHPUnit/System/PivotByQueryParamTest.php b/tests/PHPUnit/System/PivotByQueryParamTest.php
new file mode 100644
index 0000000000..358b9b03c0
--- /dev/null
+++ b/tests/PHPUnit/System/PivotByQueryParamTest.php
@@ -0,0 +1,189 @@
+<?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\Tests\System;
+
+use Piwik\Config;
+use Piwik\Date;
+use Piwik\Tests\Fixtures\ManyVisitsWithMockLocationProvider;
+use Piwik\Tests\SystemTestCase;
+
+/**
+ * @group Core
+ * @group PivotByQueryParamTest
+ */
+class PivotByQueryParamTest extends SystemTestCase
+{
+ /**
+ * @var ManyVisitsWithMockLocationProvider
+ */
+ public static $fixture = null;
+
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+
+ Config::getInstance()->General['pivot_by_filter_enable_fetch_by_segment'] = 1;
+ }
+
+ public function test_PivotBySubtableDimension_CreatesCorrectPivotTable()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'pivotBy' => 'Referrers.SearchEngine',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1,
+ 'disable_queued_filters' => 1 // test that prepending doesn't happen w/ this
+ ));
+ }
+
+ public function test_PivotBySubtableDimension_WhenEntireHirearchyIsNotLoaded()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'pivotBy' => 'Referrers.SearchEngine',
+ 'pivotByColumn' => '', // also test default pivot column
+ 'pivotByColumnLimit' => -1,
+ 'expanded' => 0
+ ));
+ }
+
+ public function test_PivotBySegment_CreatesCorrectPivotTable()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'pivotBy' => 'UserCountry.City',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1
+ ));
+ }
+
+ public function test_PivotBySegment_CreatesCorrectPivotTable_WhenSegmentUsedInRequest()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'segment' => 'browserCode==FF',
+ 'pivotBy' => 'UserCountry.City',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1
+ ));
+ }
+
+ public function test_PivotByParam_PlaysNiceWithOtherQueryParams()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'pivotBy' => 'Referrers.SearchEngine',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1,
+ 'flat' => 1,
+ 'totals' => 1,
+ 'disable_queued_filters' => 1,
+ 'disable_generic_filters' => 1,
+ 'showColumns' => 'Google,Bing'
+ ));
+ }
+
+ public function test_PivotByParam_PlaysNiceWithQueuedFilters()
+ {
+ // TODO: known issue: some segment/report relationships are more complicated; for example, UserCountry.GetCity labels are combinations
+ // of city, region & country dimensions, so the segment to get an intersected table needs all 3 of those.
+
+ $this->markTestSkipped("Not working right now.");
+
+ $this->assertApiResponseEqualsExpected("UserSettings.getBrowser", array( // should have logo metadata in output
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'pivotBy' => 'UserCountry.City', // testing w/ report that has no subtable report
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1
+ ));
+ }
+
+ public function test_PivotByParam_WorksWithReportWhoseSubtableIsSelf()
+ {
+ $this->assertApiResponseEqualsExpected("Actions.getPageUrls", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'pivotBy' => 'Actions.PageUrl',
+ 'pivotByColumn' => 'nb_hits',
+ 'pivotByColumnLimit' => -1
+ ));
+ }
+
+ public function test_PivotByParam_WorksWithColumnLimiting()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'pivotBy' => 'UserCountry.City',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => 2
+ ));
+ }
+
+ public function test_PivotByParam_WorksWithJsonOutput()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'format' => 'json',
+ 'pivotBy' => 'UserCountry.City',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1
+ ));
+ }
+
+ public function test_PivotByParam_WorksWithCsvOutput()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => self::$fixture->idSite,
+ 'date' => Date::factory(self::$fixture->dateTime)->toString(),
+ 'period' => 'week',
+ 'format' => 'csv',
+ 'pivotBy' => 'UserCountry.City',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1
+ ));
+ }
+
+ public function test_PivotByParam_PlaysNiceWithDataTableMaps()
+ {
+ $this->assertApiResponseEqualsExpected("Referrers.getKeywords", array(
+ 'idSite' => 'all',
+ 'date' => '2010-01-01,2010-01-07',
+ 'period' => 'day',
+ 'pivotBy' => 'UserCountry.City',
+ 'pivotByColumn' => 'nb_visits',
+ 'pivotByColumnLimit' => -1
+ ));
+ }
+ public function assertApiResponseEqualsExpected($apiMethod, $queryParams)
+ {
+ if(self::isPhpVersion53()) {
+ // 5.3.3 space encoding fail eg. https://travis-ci.org/piwik/piwik/jobs/35920420
+ $this->markTestSkipped();
+ }
+ parent::assertApiResponseEqualsExpected($apiMethod, $queryParams);
+ }
+}
+
+PivotByQueryParamTest::$fixture = new ManyVisitsWithMockLocationProvider();