From 9af4e95aa976f3a6533e95b776b5298f73e5f916 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Wed, 4 Oct 2017 09:22:01 +1300 Subject: Better segment editor and fixes (#12040) * column tweak * fix install * more tweaks * rename column to dimension * various fixes * added new control expandable select * starting to refactor segment selector * make segment editor work again * use translation keys * defined some metrics * set types * simplify * simplify * fix join generator * add possibility to use custom join table names when using query builder and it uses an inner query * fix bug in query selector when selecting same field name from different tables twice * more metadata * more tweaks * improve selector * add possibility to use custom entity names * also processed archived metrics * generate sql filter, suggested values callback, and accept values automatically for columns with enums * several tweaks * focus search field when opening it * various tweaks * added missing method * format and fix more metadata * more fixes * better definition * define custom filter * fix definition * fix various tests * fix more tests * fix bug in logquery builder * fix referrerurl segment was missing * fix some tests * fix more tests * add group * refactor for better definition * fix a bug in log query builder when similar columns are used in archiver * add goal metrics * various fixes * make datatable row more flexible * various fixes and visualization enhancements * simply segment editor and make it smaller * remove trailing comma * various fixes and added new dimension * fix formatting of returning customer * added missing primary key * fixes * various fixes and improvements * make sure to update segment definition when selecting a value from auto complete list * various fixes and more metrics * more metrics * more dimensions and fixes * fix some tests * fix some integration tests * update submodule * fix some system tests * fix ui tests * trigger new test run * fix more ui tests * fix system tests * update submodule * fix categories * sort segments by category for more consistency * add custom variables * some translations and fixes * add minute segment * more segments * added plurals * added some docs * fix test * fix tests * fix tests * added suggested values * fix some tests * various fixes * fix more tests * allow to select segments on any site * make sure to include file * added doc block * fix some system tests * fix most system tests * fix ui test * fix system test * adjust examples * added more tests and docs * no metrics for these dimensions * added developer changelog and made some classes public api * some fixes for entity names * add possibility to set format metrics in test * more consistency in defining the name * get idsites only if provided * fix integration tests * added another segment for visit start hour and visit start minute * more clear name for segment * use old segment name to not break bc * various fixes * more test fixes * fix no suggested values for new segment * add event value * for boolean dimensions only sum metric * update available widgets when updating reporting menu * Add new segments in developer changelog + typo * fix system tests * fix screenshot test --- .../Integration/Category/CategoryListTest.php | 3 + .../Columns/ComputedMetricFactoryTest.php | 62 +++ .../Columns/DimensionMetricFactoryTest.php | 159 ++++++++ .../PHPUnit/Integration/Columns/DimensionTest.php | 415 +++++++++++++-------- .../Integration/Plugin/ArchivedMetricTest.php | 131 +++++++ .../Integration/Plugin/ComputedMetricTest.php | 136 +++++++ .../Plugin/Dimension/ActionDimensionTest.php | 8 +- .../Plugin/Dimension/ConversionDimensionTest.php | 8 +- .../Plugin/Dimension/VisitDimensionTest.php | 36 +- tests/PHPUnit/Integration/SegmentTest.php | 97 ++++- ...erverHour__API.getSuggestedValuesForSegment.xml | 27 ++ ...t_actionServerHour__VisitsSummary.get_range.xml | 12 + ...verMinute__API.getSuggestedValuesForSegment.xml | 34 ++ ...actionServerMinute__VisitsSummary.get_range.xml | 12 + ...eviceType__API.getSuggestedValuesForSegment.xml | 15 +- ..._position__API.getSuggestedValuesForSegment.xml | 2 + ...errerType__API.getSuggestedValuesForSegment.xml | 2 + ...rceStatus__API.getSuggestedValuesForSegment.xml | 3 + ...verMinute__API.getSuggestedValuesForSegment.xml | 34 ++ ...sitEndServerMinute__VisitsSummary.get_range.xml | 12 + ...calMinute__API.getSuggestedValuesForSegment.xml | 34 ++ ...t_visitLocalMinute__VisitsSummary.get_range.xml | 12 + ...verMinute__API.getSuggestedValuesForSegment.xml | 34 ++ ..._visitServerMinute__VisitsSummary.get_range.xml | 12 + ...erverHour__API.getSuggestedValuesForSegment.xml | 27 ++ ...sitStartServerHour__VisitsSummary.get_range.xml | 12 + ...verMinute__API.getSuggestedValuesForSegment.xml | 34 ++ ...tStartServerMinute__VisitsSummary.get_range.xml | 12 + ...sitorType__API.getSuggestedValuesForSegment.xml | 1 + ...ldKeepEmptyRows__API.getProcessedReport_day.xml | 4 +- ...ts_hideColumns___API.getProcessedReport_day.xml | 4 +- ...ocessedMetrics___API.getProcessedReport_day.xml | 4 +- ...ts_showColumns___API.getProcessedReport_day.xml | 4 +- ...on_pageTitlesMulti__API.getRowEvolution_day.xml | 2 +- ...n_pageTitlesMulti__API.getRowEvolution_week.xml | 2 +- ...olution_pageTitles__API.getRowEvolution_day.xml | 2 +- ...lution_pageTitles__API.getRowEvolution_week.xml | 2 +- ...firstSite_lastN__API.getProcessedReport_day.xml | 4 +- ...rstSite_lastN__API.getProcessedReport_month.xml | 4 +- ...firstSite_lastN__API.getProcessedReport_day.xml | 4 +- ...duledReports.generateReport_month.original.html | 8 +- ...duledReports.generateReport_month.original.html | 8 +- ...eduledReports.generateReport_month.original.pdf | Bin 551714 -> 551783 bytes ...etReportMetadata__API.getReportMetadata_day.xml | 8 +- ...iGetReportMetadata__API.getSegmentsMetadata.xml | 267 +++++++------ ...onPerServerTime__API.getProcessedReport_day.xml | 4 +- ...eduledReports.generateReport_week.original.html | 8 +- ...eduledReports.generateReport_week.original.html | 8 +- ...heduledReports.generateReport_week.original.pdf | Bin 568483 -> 568560 bytes .../LogQueryBuilder/JoinGeneratorTest.php | 38 +- .../Filter/AddSegmentFilterBySegmentValueTest.php | 8 - tests/PHPUnit/Unit/DeprecatedMethodsTest.php | 3 + 52 files changed, 1420 insertions(+), 362 deletions(-) create mode 100644 tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php create mode 100644 tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php create mode 100644 tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php create mode 100644 tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__VisitsSummary.get_range.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__VisitsSummary.get_range.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_interaction_position__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__VisitsSummary.get_range.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__VisitsSummary.get_range.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__VisitsSummary.get_range.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__VisitsSummary.get_range.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__API.getSuggestedValuesForSegment.xml create mode 100644 tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__VisitsSummary.get_range.xml (limited to 'tests/PHPUnit') diff --git a/tests/PHPUnit/Integration/Category/CategoryListTest.php b/tests/PHPUnit/Integration/Category/CategoryListTest.php index 4c8cc4ec57..824339fb13 100644 --- a/tests/PHPUnit/Integration/Category/CategoryListTest.php +++ b/tests/PHPUnit/Integration/Category/CategoryListTest.php @@ -42,7 +42,10 @@ class CategoryListTest extends IntegrationTestCase 'Referrers_Referrers', 'Goals_Goals', 'Goals_Ecommerce', + 'Events_Events', + 'UserCountry_VisitLocation', 'Live!', + 'CustomVariables_CustomVariables', 'ExampleUI_UiFramework' ), array_keys($list->getCategories())); } diff --git a/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php b/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php new file mode 100644 index 0000000000..8995c1e1b6 --- /dev/null +++ b/tests/PHPUnit/Integration/Columns/ComputedMetricFactoryTest.php @@ -0,0 +1,62 @@ +factory = new ComputedMetricFactory(MetricsList::get()); + } + + public function tearDown() + { + Translate::unloadEnglishTranslation(); + parent::tearDown(); + } + + public function test_createComputedMetric_createAvgMetric() + { + $metric = $this->factory->createComputedMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + + $this->assertSame('avg_bounce_count_per_visits', $metric->getName()); + $this->assertSame('Avg. Actions In Visit per Visit', $metric->getTranslatedName()); + $this->assertSame('Average value of "Actions In Visit" per "Visits".', $metric->getDocumentation()); + $this->assertSame('General_Visitors', $metric->getCategoryId()); + } + + public function test_createComputedMetric_createRateMetric() + { + $metric = $this->factory->createComputedMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_RATE); + + $this->assertSame('bounce_count_visits_rate', $metric->getName()); + $this->assertSame('Bounces Rate', $metric->getTranslatedName()); + $this->assertSame('The ratio of "Actions In Visit" out of all "Visits".', $metric->getDocumentation()); + $this->assertSame('General_Visitors', $metric->getCategoryId()); + } + +} \ No newline at end of file diff --git a/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php b/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php new file mode 100644 index 0000000000..4f03b9f8cc --- /dev/null +++ b/tests/PHPUnit/Integration/Columns/DimensionMetricFactoryTest.php @@ -0,0 +1,159 @@ +country = new Country(); + } + + public function tearDown() + { + Translate::unloadEnglishTranslation(); + parent::tearDown(); + } + + private function makeFactory($dimension) + { + return new DimensionMetricFactory($dimension); + } + + public function test_createMetric_count() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createMetric(ArchivedMetric::AGGREGATION_COUNT); + + $this->assertSame('nb_usercountry_country', $metric->getName()); + $this->assertSame('Countries', $metric->getTranslatedName()); + $this->assertSame('The number of Countries', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertSame('count(log_visit.location_country)', $metric->getQuery()); + } + + public function test_createMetric_uniqueCount() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createMetric(ArchivedMetric::AGGREGATION_UNIQUE); + + $this->assertSame('nb_uniq_usercountry_country', $metric->getName()); + $this->assertSame('Unique Countries', $metric->getTranslatedName()); + $this->assertSame('The unique number of Countries', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertSame('count(distinct log_visit.location_country)', $metric->getQuery()); + } + + public function test_createMetric_sum() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createMetric(ArchivedMetric::AGGREGATION_SUM); + + $this->assertSame('sum_usercountry_country', $metric->getName()); + $this->assertSame('Total Countries', $metric->getTranslatedName()); + $this->assertSame('The total number (sum) of Countries', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertSame('sum(log_visit.location_country)', $metric->getQuery()); + } + + public function test_createMetric_min() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createMetric(ArchivedMetric::AGGREGATION_MIN); + + $this->assertSame('min_usercountry_country', $metric->getName()); + $this->assertSame('Min Countries', $metric->getTranslatedName()); + $this->assertSame('The minimum value for Countries', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertSame('min(log_visit.location_country)', $metric->getQuery()); + } + + public function test_createMetric_max() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createMetric(ArchivedMetric::AGGREGATION_MAX); + + $this->assertSame('max_usercountry_country', $metric->getName()); + $this->assertSame('Max Countries', $metric->getTranslatedName()); + $this->assertSame('The maximum value for Countries', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertSame('max(log_visit.location_country)', $metric->getQuery()); + } + + public function test_createMetric_withValue() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createMetric(ArchivedMetric::AGGREGATION_COUNT_WITH_NUMERIC_VALUE); + + $this->assertSame('nb_with_usercountry_country', $metric->getName()); + $this->assertSame('Entries with Country', $metric->getTranslatedName()); + $this->assertSame('The number of entries that have a value set for Country', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertSame('sum(if(log_visit.location_country > 0, 1, 0))', $metric->getQuery()); + } + + + public function test_createCustomMetric() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createCustomMetric($name = 'sum_times_10', $translated = 'MyMetric', $aggregation = 'sum(%s) * 10', $documentation = 'FoobarBaz'); + + $this->assertSame($name, $metric->getName()); + $this->assertSame($translated, $metric->getTranslatedName()); + $this->assertSame($documentation, $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertSame('sum(log_visit.location_country) * 10', $metric->getQuery()); + } + + public function test_createComputedMetric_average() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createComputedMetric($metricName1 = 'bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + + $this->assertSame('avg_bounce_count_per_visits', $metric->getName()); + $this->assertSame('Avg. Actions In Visit per Visit', $metric->getTranslatedName()); + $this->assertSame('Average value of "Actions In Visit" per "Visits".', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertCount(2, $metric->getDependentMetrics()); + } + + public function test_createComputedMetric_rate() + { + $factory = $this->makeFactory($this->country); + $metric = $factory->createComputedMetric($metricName1 = 'bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_RATE); + + $this->assertSame('bounce_count_visits_rate', $metric->getName()); + $this->assertSame('Bounces Rate', $metric->getTranslatedName()); + $this->assertSame('The ratio of "Actions In Visit" out of all "Visits".', $metric->getDocumentation()); + $this->assertSame('UserCountry_VisitLocation', $metric->getCategoryId()); + $this->assertCount(2, $metric->getDependentMetrics()); + } + + +} \ No newline at end of file diff --git a/tests/PHPUnit/Integration/Columns/DimensionTest.php b/tests/PHPUnit/Integration/Columns/DimensionTest.php index 0e51177673..286ee4fb55 100644 --- a/tests/PHPUnit/Integration/Columns/DimensionTest.php +++ b/tests/PHPUnit/Integration/Columns/DimensionTest.php @@ -6,217 +6,310 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -namespace Piwik\Plugins\Test\Columns -{ +namespace Piwik\Tests\Integration\Columns; + // there is a test that requires the class to be defined in a plugin - use Piwik\Columns\Dimension; - use Piwik\Plugin\Segment; +use Piwik\Columns\Dimension; +use Piwik\Plugin\Segment; +use Piwik\Metrics\Formatter; +use Piwik\Plugin\Dimension\ActionDimension; +use Piwik\Plugin\Dimension\ConversionDimension; +use Piwik\Plugin\Dimension\VisitDimension; +use Piwik\Plugin\Manager; +use Piwik\Tests\Framework\Fixture; +use Piwik\Tests\Framework\TestCase\IntegrationTestCase; +use Piwik\Translate; + +class CustomDimensionTest extends Dimension +{ + protected $columnName = 'test_dimension'; + protected $columnType = 'INTEGER (10) DEFAULT 0'; + protected $dbTableName = 'log_visit'; - class DimensionTest extends Dimension + public function getId() { - protected $columnName = 'test_dimension'; - protected $columnType = 'INTEGER (10) DEFAULT 0'; + return $this->generateIdFromClass('Piwik\Plugins\Test\Columns\DimensionTest'); + } - public function set($param, $value) - { - $this->$param = $value; - } + public function hasImplementedEvent($method) + { + $method = new \ReflectionMethod($this, $method); + $declaringClass = $method->getDeclaringClass(); - protected function configureSegments() - { - $segment = new Segment(); - $segment->setSegment('exitPageUrl'); - $segment->setName('Actions_ColumnExitPageURL'); - $segment->setCategory('General_Visit'); - $this->addSegment($segment); - - // custom type and sqlSegment - $segment = new Segment(); - $segment->setSegment('exitPageUrl'); - $segment->setSqlSegment('customValue'); - $segment->setType(Segment::TYPE_METRIC); - $segment->setName('Actions_ColumnExitPageURL'); - $segment->setCategory('General_Visit'); - $this->addSegment($segment); - } + return 0 === strpos($declaringClass->name, 'Piwik\Tests'); + } + + public function set($param, $value) + { + $this->$param = $value; + } + + public function setColumnType($columnType) + { + $this->columnType = $columnType; + } + + protected function configureSegments() + { + $segment = new Segment(); + $segment->setSegment('exitPageUrl'); + $segment->setName('Actions_ColumnExitPageURL'); + $segment->setCategory('General_Visit'); + $this->addSegment($segment); + + // custom type and sqlSegment + $segment = new Segment(); + $segment->setSegment('exitPageUrl'); + $segment->setSqlSegment('customValue'); + $segment->setType(Segment::TYPE_METRIC); + $segment->setName('Actions_ColumnExitPageURL'); + $segment->setCategory('General_Visit'); + $this->addSegment($segment); } } -namespace Piwik\Tests\Integration\Columns -{ - use Piwik\Columns\Dimension; - use Piwik\Config; - use Piwik\Plugin\Dimension\ActionDimension; - use Piwik\Plugin\Dimension\ConversionDimension; - use Piwik\Plugin\Dimension\VisitDimension; - use Piwik\Plugin\Segment; - use Piwik\Plugin\Manager; - use Piwik\Plugins\Test\Columns\DimensionTest; - use Piwik\Plugins\Test\FakeActionDimension; - use Piwik\Tests\Framework\TestCase\IntegrationTestCase; +/** + * @group Core + */ +class ColumnDimensionTest extends IntegrationTestCase +{ /** - * @group Core + * @var CustomDimensionTest */ - class ColumnDimensionTest extends IntegrationTestCase + private $dimension; + + public function setUp() { - /** - * @var FakeActionDimension - */ - private $dimension; + parent::setUp(); - public function setUp() - { - parent::setUp(); + Translate::loadEnglishTranslation(); - Manager::getInstance()->unloadPlugins(); - Manager::getInstance()->doNotLoadAlwaysActivatedPlugins(); + Fixture::createWebsite('2014-04-05 01:02:03'); - $this->dimension = new DimensionTest(); - } + Manager::getInstance()->unloadPlugins(); + Manager::getInstance()->doNotLoadAlwaysActivatedPlugins(); - public function test_hasImplementedEvent_shouldDetectWhetherAMethodWasOverwrittenInTheActualPluginClass() - { - $this->assertTrue($this->dimension->hasImplementedEvent('set')); - $this->assertTrue($this->dimension->hasImplementedEvent('configureSegments')); + $this->dimension = new CustomDimensionTest(); + } - $this->assertFalse($this->dimension->hasImplementedEvent('getSegments')); - } + public function tearDown() + { + Translate::unloadEnglishTranslation(); + parent::tearDown(); + } - public function test_getColumnName_shouldReturnTheNameOfTheColumn() - { - $this->assertSame('test_dimension', $this->dimension->getColumnName()); - } + public function test_hasImplementedEvent_shouldDetectWhetherAMethodWasOverwrittenInTheActualPluginClass() + { + $this->assertTrue($this->dimension->hasImplementedEvent('set')); + $this->assertTrue($this->dimension->hasImplementedEvent('configureSegments')); - public function test_hasColumnType_shouldDetectWhetherAColumnTypeIsSet() - { - $this->assertTrue($this->dimension->hasColumnType()); + $this->assertFalse($this->dimension->hasImplementedEvent('getSegments')); + } - $this->dimension->set('columnType', ''); - $this->assertFalse($this->dimension->hasColumnType()); - } + public function test_getColumnName_shouldReturnTheNameOfTheColumn() + { + $this->assertSame('test_dimension', $this->dimension->getColumnName()); + } - public function test_getName_ShouldNotReturnANameByDefault() - { - $this->assertSame('', $this->dimension->getName()); - } + public function test_hasColumnType_shouldDetectWhetherAColumnTypeIsSet() + { + $this->assertTrue($this->dimension->hasColumnType()); + + $this->dimension->set('columnType', ''); + $this->assertFalse($this->dimension->hasColumnType()); + } + + public function test_getName_ShouldNotReturnANameByDefault() + { + $this->assertSame('', $this->dimension->getName()); + } - public function test_getAllDimensions_shouldReturnAllKindOfDimensions() - { - Manager::getInstance()->loadPlugins(array('Actions', 'Events', 'DevicesDetector', 'Goals', 'CustomVariables')); - - $dimensions = Dimension::getAllDimensions(); - - $this->assertGreaterThan(20, count($dimensions)); - - $foundConversion = false; - $foundVisit = false; - $foundAction = false; - $foundNormal = false; - - foreach ($dimensions as $dimension) { - if ($dimension instanceof ConversionDimension) { - $foundConversion = true; - } else if ($dimension instanceof ActionDimension) { - $foundAction = true; - } else if ($dimension instanceof VisitDimension) { - $foundVisit = true; - } else if ($dimension instanceof Dimension) { - $foundNormal = true; - } else { - $this->fail('Unexpected dimension class found'); - } - - $this->assertRegExp('/Piwik.Plugins.(Actions|Events|DevicesDetector|Goals|CustomVariables).Columns/', get_class($dimension)); + public function test_getAllDimensions_shouldReturnAllKindOfDimensions() + { + Manager::getInstance()->loadPlugins(array('Actions', 'Events', 'DevicesDetector', 'Goals', 'CustomVariables')); + + $dimensions = Dimension::getAllDimensions(); + + $this->assertGreaterThan(20, count($dimensions)); + + $foundConversion = false; + $foundVisit = false; + $foundAction = false; + $foundNormal = false; + + foreach ($dimensions as $dimension) { + if ($dimension instanceof ConversionDimension) { + $foundConversion = true; + } else if ($dimension instanceof ActionDimension) { + $foundAction = true; + } else if ($dimension instanceof VisitDimension) { + $foundVisit = true; + } else if ($dimension instanceof Dimension) { + $foundNormal = true; + } else { + $this->fail('Unexpected dimension class found'); } - $this->assertTrue($foundConversion); - $this->assertTrue($foundAction); - $this->assertTrue($foundVisit); - $this->assertTrue($foundNormal); + if (get_class($dimension) === 'Piwik\Plugins\CustomVariables\CustomDimension') { + continue; + } + + $this->assertRegExp('/Piwik.Plugins.(Actions|Events|DevicesDetector|Goals|CustomVariables).Columns/', get_class($dimension)); } - public function test_getDimensions_shouldReturnAllKindOfDimensionsThatBelongToASpecificPlugin() - { - Manager::getInstance()->loadPlugins(array('Actions', 'Events', 'DevicesDetector', 'Goals')); + $this->assertTrue($foundConversion); + $this->assertTrue($foundAction); + $this->assertTrue($foundVisit); + $this->assertTrue($foundNormal); + } - $dimensions = Dimension::getDimensions(Manager::getInstance()->loadPlugin('Actions')); + public function test_getDimensions_shouldReturnAllKindOfDimensionsThatBelongToASpecificPlugin() + { + Manager::getInstance()->loadPlugins(array('Actions', 'Events', 'DevicesDetector', 'Goals')); - $this->assertGreaterThan(10, count($dimensions)); + $dimensions = Dimension::getDimensions(Manager::getInstance()->loadPlugin('Actions')); - $foundVisit = false; - $foundAction = false; + $this->assertGreaterThan(10, count($dimensions)); - foreach ($dimensions as $dimension) { - if ($dimension instanceof ActionDimension) { - $foundAction = true; - } else if ($dimension instanceof VisitDimension) { - $foundVisit = true; - } + $foundVisit = false; + $foundAction = false; - $this->assertRegExp('/Piwik.Plugins.Actions.Columns/', get_class($dimension)); + foreach ($dimensions as $dimension) { + if ($dimension instanceof ActionDimension) { + $foundAction = true; + } else if ($dimension instanceof VisitDimension) { + $foundVisit = true; } - $this->assertTrue($foundAction); - $this->assertTrue($foundVisit); + $this->assertRegExp('/Piwik.Plugins.Actions.Columns/', get_class($dimension)); } - public function test_getDimensions_shouldReturnConversionDimensionsThatBelongToASpecificPlugin() - { - Manager::getInstance()->loadPlugins(array('Actions', 'Events', 'DevicesDetector', 'Goals')); + $this->assertTrue($foundAction); + $this->assertTrue($foundVisit); + } - $dimensions = Dimension::getDimensions(Manager::getInstance()->loadPlugin('Goals')); + public function test_getDimensions_shouldReturnConversionDimensionsThatBelongToASpecificPlugin() + { + Manager::getInstance()->loadPlugins(array('Actions', 'Events', 'DevicesDetector', 'Goals')); - $this->assertGreaterThan(2, count($dimensions)); + $dimensions = Dimension::getDimensions(Manager::getInstance()->loadPlugin('Goals')); - $foundConversion = false; + $this->assertGreaterThan(2, count($dimensions)); - foreach ($dimensions as $dimension) { - if ($dimension instanceof ConversionDimension) { - $foundConversion = true; - } + $foundConversion = false; - $this->assertRegExp('/Piwik.Plugins.Goals.Columns/', get_class($dimension)); + foreach ($dimensions as $dimension) { + if ($dimension instanceof ConversionDimension) { + $foundConversion = true; } - $this->assertTrue($foundConversion); + $this->assertRegExp('/Piwik.Plugins.Goals.Columns/', get_class($dimension)); } - public function test_getSegment_ShouldReturnConfiguredSegments() - { - $segments = $this->dimension->getSegments(); + $this->assertTrue($foundConversion); + } - $this->assertCount(2, $segments); - $this->assertInstanceOf('\Piwik\Plugin\Segment', $segments[0]); - $this->assertInstanceOf('\Piwik\Plugin\Segment', $segments[1]); - } + public function test_getSegment_ShouldReturnConfiguredSegments() + { + $segments = $this->dimension->getSegments(); - public function test_addSegment_ShouldPrefilSomeSegmentValuesIfNotDefinedYet() - { - $segments = $this->dimension->getSegments(); + $this->assertCount(2, $segments); + $this->assertInstanceOf('\Piwik\Plugin\Segment', $segments[0]); + $this->assertInstanceOf('\Piwik\Plugin\Segment', $segments[1]); + } - $this->assertEquals(Segment::TYPE_DIMENSION, $segments[0]->getType()); - } + /** + * @param $expectedType + * @param $columnType + * @dataProvider getTypeProvider + */ + public function test_getType_shouldGuessTypeBasedOnColumnType($expectedType, $columnType) + { + $this->dimension->setColumnType($columnType); + $this->assertSame($expectedType, $this->dimension->getType()); + } - public function test_addSegment_ShouldNotOverwritePreAssignedValues() - { - $segments = $this->dimension->getSegments(); + public function getTypeProvider() + { + return array( + array($expected = Dimension::TYPE_NUMBER, $columnType = 'INTEGER (10) DEFAULT 0'), + array($expected = Dimension::TYPE_NUMBER, $columnType = 'INTEGER(10) DEFAULT 0'), + array($expected = Dimension::TYPE_NUMBER, $columnType = 'INT(10) DEFAULT 0'), + array($expected = Dimension::TYPE_NUMBER, $columnType = 'int(10) DEFAULT 0'), + array($expected = Dimension::TYPE_NUMBER, $columnType = 'SMALLINT(10) DEFAULT 0'), + array($expected = Dimension::TYPE_FLOAT, $columnType = 'FLOAT (10) DEFAULT 0'), + array($expected = Dimension::TYPE_FLOAT, $columnType = 'DECIMAL(10) DEFAULT 0'), + array($expected = Dimension::TYPE_BINARY, $columnType = 'BINARY(8)'), + array($expected = Dimension::TYPE_TIMESTAMP, $columnType = 'timestamp null'), + array($expected = Dimension::TYPE_TIMESTAMP, $columnType = 'timeStAmp null'), + array($expected = Dimension::TYPE_DATETIME, $columnType = 'DATETIME NOT NULL'), + array($expected = Dimension::TYPE_DATE, $columnType = 'DATE NOT NULL'), + array($expected = Dimension::TYPE_TEXT, $columnType = ''), + ); + } - $this->assertEquals(Segment::TYPE_METRIC, $segments[1]->getType()); - } + public function test_addSegment_ShouldPrefilSomeSegmentValuesIfNotDefinedYetAndGuessTypeMetric() + { + $segments = $this->dimension->getSegments(); - public function test_getId_ShouldCorrectlyGenerateIdFromDimensionsQualifiedClassName() - { - $this->assertEquals("Test.DimensionTest", $this->dimension->getId()); - } + $this->assertEquals(Segment::TYPE_METRIC, $segments[0]->getType()); + } - public function test_factory_ShouldCreateDimensionFromDimensionId() - { - Manager::getInstance()->loadPlugins(array('ExampleTracker')); + public function test_addSegment_ShouldPrefilSomeSegmentValuesIfNotDefinedYetAndGuessTypeDimension() + { + $this->dimension->setColumnType('TEXT NOT NULL'); + $segments = $this->dimension->getSegments(); - $dimension = Dimension::factory("ExampleTracker.ExampleDimension"); - $this->assertInstanceOf('Piwik\Plugins\ExampleTracker\Columns\ExampleDimension', $dimension); - } - } -} \ No newline at end of file + $this->assertEquals(Segment::TYPE_DIMENSION, $segments[0]->getType()); + } + + public function test_addSegment_ShouldNotOverwritePreAssignedValues() + { + $segments = $this->dimension->getSegments(); + + $this->assertEquals(Segment::TYPE_METRIC, $segments[1]->getType()); + } + + public function test_getId_ShouldCorrectlyGenerateIdFromDimensionsQualifiedClassName() + { + $this->assertEquals("Test.DimensionTest", $this->dimension->getId()); + } + + public function test_factory_ShouldCreateDimensionFromDimensionId() + { + Manager::getInstance()->loadPlugins(array('ExampleTracker')); + + $dimension = Dimension::factory("ExampleTracker.ExampleDimension"); + $this->assertInstanceOf('Piwik\Plugins\ExampleTracker\Columns\ExampleDimension', $dimension); + } + + + /** + * @dataProvider getFormatValueProvider + */ + public function test_formatValue($type, $value, $expected) + { + $formatter = new Formatter(); + $this->dimension->setType($type); + $formatted = $this->dimension->formatValue($value, $idSite = 1, $formatter); + + $this->assertEquals($expected, $formatted); + } + + public function getFormatValueProvider() + { + return array( + array($type = Dimension::TYPE_NUMBER, $value = 5.354, $expected = 5), + array($type = Dimension::TYPE_FLOAT, $value = 5.354, $expected = 5.35), + array($type = Dimension::TYPE_MONEY, $value = 5.392, $expected = '$ 5.39'), + array($type = Dimension::TYPE_PERCENT, $value = 0.343, $expected = '34.3%'), + array($type = Dimension::TYPE_DURATION_S, $value = 121, $expected = '00:02:01'), + array($type = Dimension::TYPE_DURATION_MS, $value = 0.392, $expected = '0.39s'), + array($type = Dimension::TYPE_BYTE, $value = 3912, $expected = '3.8 K'), + array($type = Dimension::TYPE_BOOL, $value = 0, $expected = 'No'), + array($type = Dimension::TYPE_BOOL, $value = 1, $expected = 'Yes'), + ); + } +} diff --git a/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php b/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php new file mode 100644 index 0000000000..1a9a19526a --- /dev/null +++ b/tests/PHPUnit/Integration/Plugin/ArchivedMetricTest.php @@ -0,0 +1,131 @@ +dimension = new Country(); + $this->metric = $this->makeMetric('%s'); + } + + public function tearDown() + { + Translate::unloadEnglishTranslation(); + parent::tearDown(); + } + + private function makeMetric($aggregation) + { + return new ArchivedMetric($this->dimension, $aggregation); + } + + /** + * @dataProvider getFormatValueProvider + */ + public function test_formatValue($type, $value, $expected) + { + $formatter = new Formatter(); + $this->metric->setType($type); + + $table = new DataTable(); + $table->setMetadata('site', new Site(1)); + $this->metric->beforeFormat(null, $table); + $formatted = $this->metric->format($value, $formatter); + + $this->assertEquals($expected, $formatted); + } + + public function getFormatValueProvider() + { + return array( + array($type = Dimension::TYPE_NUMBER, $value = 5.354, $expected = 5), + array($type = Dimension::TYPE_FLOAT, $value = 5.354, $expected = 5.35), + array($type = Dimension::TYPE_MONEY, $value = 5.392, $expected = '$ 5.39'), + array($type = Dimension::TYPE_PERCENT, $value = 0.343, $expected = '34.3%'), + array($type = Dimension::TYPE_DURATION_S, $value = 121, $expected = '2 min 1s'), + array($type = Dimension::TYPE_DURATION_MS, $value = 392, $expected = '0.39s'), + array($type = Dimension::TYPE_BYTE, $value = 3912, $expected = '3.8 K'), + ); + } + public function test_getQuery_returnsDefaultColumns() + { + $this->assertSame('log_visit.location_country', $this->metric->getQuery()); + } + + public function test_getQuery_whenNoAggregationSet() + { + $metric = $this->makeMetric(''); + $this->assertSame('log_visit.location_country', $metric->getQuery()); + } + + public function test_getQuery_whenAggregationSet() + { + $metric = $this->makeMetric('count(%s)'); + $this->assertSame('count(log_visit.location_country)', $metric->getQuery()); + } + + public function test_setQuery() + { + $this->metric->setQuery('count(log_visit.foobar) + 1'); + $this->assertSame('count(log_visit.foobar) + 1', $this->metric->getQuery()); + } + + public function test_setDimension() + { + $this->assertSame($this->dimension, $this->metric->getDimension()); + } + + public function test_getDbTableName() + { + $this->assertSame('log_visit', $this->metric->getDbTableName()); + } + + public function test_setCategory_getCategoryId() + { + $this->assertSame('', $this->metric->getCategoryId()); + $this->metric->setCategory('General_Visitors'); + $this->assertSame('General_Visitors', $this->metric->getCategoryId()); + } + + +} diff --git a/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php b/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php new file mode 100644 index 0000000000..7149271535 --- /dev/null +++ b/tests/PHPUnit/Integration/Plugin/ComputedMetricTest.php @@ -0,0 +1,136 @@ +makeMetric('bonuce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + + $formatter = new Formatter(); + $metric->setType($type); + + $table = new DataTable(); + $table->setMetadata('site', new Site(1)); + $metric->beforeFormat(null, $table); + $formatted = $metric->format($value, $formatter); + + $this->assertEquals($expected, $formatted); + } + + public function getFormatValueProvider() + { + return array( + array($type = Dimension::TYPE_NUMBER, $value = 5.354, $expected = 5.4), + array($type = Dimension::TYPE_FLOAT, $value = 5.354, $expected = 5.35), + array($type = Dimension::TYPE_MONEY, $value = 5.392, $expected = '$ 5.39'), + array($type = Dimension::TYPE_PERCENT, $value = 0.343, $expected = '34.3%'), + array($type = Dimension::TYPE_DURATION_S, $value = 121, $expected = '2 min 1s'), + array($type = Dimension::TYPE_DURATION_MS, $value = 392, $expected = '0.39s'), + array($type = Dimension::TYPE_BYTE, $value = 392, $expected = '392 B'), + ); + } + + public function test_getName() + { + $metric = $this->makeMetric('bounces', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + $this->assertSame('avg_bounces_per_visits', $metric->getName()); + + $metric = $this->makeMetric('bounces', 'nb_uniq_visits', ComputedMetric::AGGREGATION_AVG); + $this->assertSame('avg_bounces_per_uniq_visits', $metric->getName()); + + $metric = $this->makeMetric('sum_bounces', 'nb_uniq_visits', ComputedMetric::AGGREGATION_AVG); + $this->assertSame('avg_sum_bounces_per_uniq_visits', $metric->getName()); + + $metric = $this->makeMetric('bounces', 'nb_visits', ComputedMetric::AGGREGATION_RATE); + $this->assertSame('bounces_visits_rate', $metric->getName()); + + $metric = $this->makeMetric('bounces', 'nb_uniq_visits', ComputedMetric::AGGREGATION_RATE); + $this->assertSame('bounces_uniq_visits_rate', $metric->getName()); + + $metric = $this->makeMetric('sum_bounces', 'nb_uniq_visits', ComputedMetric::AGGREGATION_RATE); + $this->assertSame('sum_bounces_uniq_visits_rate', $metric->getName()); + } + + public function test_setName() + { + $metric = $this->makeMetric('bounces', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + $metric->setName('avg_bounces'); + $this->assertSame('avg_bounces', $metric->getName()); + } + + public function test_getTranslatedName() + { + $metric = $this->makeMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + $this->assertSame('Avg. Actions In Visit per Visit', $metric->getTranslatedName()); + + $metric = $this->makeMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_RATE); + $this->assertSame('Bounces Rate', $metric->getTranslatedName()); + } + + public function test_getDocumentation() + { + $metric = $this->makeMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + $this->assertSame('Average value of "Actions In Visit" per "Visits".', $metric->getDocumentation()); + + $metric = $this->makeMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_RATE); + $this->assertSame('The ratio of "Actions In Visit" out of all "Visits".', $metric->getDocumentation()); + } + + public function test_getDependentMetrics() + { + $metric = $this->makeMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + $this->assertSame(array('bounce_count', 'nb_visits'), $metric->getDependentMetrics()); + } + + public function test_setCategory() + { + $metric = $this->makeMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG); + $metric->setCategory('123'); + $this->assertSame('123', $metric->getCategoryId()); + } + +} diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php index 1666b193db..006399bffd 100644 --- a/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php +++ b/tests/PHPUnit/Integration/Plugin/Dimension/ActionDimensionTest.php @@ -17,7 +17,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase; class FakeActionDimension extends ActionDimension { protected $columnName = 'fake_action_dimension_column'; - protected $columnType = 'INTEGER (10) DEFAULT 0'; + protected $columnType = 'VARCHAR (255) DEFAULT 0'; public function set($param, $value) { @@ -79,7 +79,7 @@ class ActionDimensionTest extends IntegrationTestCase { $expected = array( 'log_link_visit_action' => array( - "ADD COLUMN `fake_action_dimension_column` INTEGER (10) DEFAULT 0" + "ADD COLUMN `fake_action_dimension_column` VARCHAR (255) DEFAULT 0" ) ); @@ -90,7 +90,7 @@ class ActionDimensionTest extends IntegrationTestCase { $expected = array( 'log_link_visit_action' => array( - "MODIFY COLUMN `fake_action_dimension_column` INTEGER (10) DEFAULT 0" + "MODIFY COLUMN `fake_action_dimension_column` VARCHAR (255) DEFAULT 0" ) ); @@ -99,7 +99,7 @@ class ActionDimensionTest extends IntegrationTestCase public function test_getVersion_shouldUseColumnTypeAsVersion() { - $this->assertEquals('INTEGER (10) DEFAULT 0', $this->dimension->getVersion()); + $this->assertEquals('VARCHAR (255) DEFAULT 0', $this->dimension->getVersion()); } public function test_getSegment_ShouldReturnConfiguredSegments() diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php index 7e6ac7191c..35cd30615d 100644 --- a/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php +++ b/tests/PHPUnit/Integration/Plugin/Dimension/ConversionDimensionTest.php @@ -17,7 +17,7 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase; class FakeConversionDimension extends ConversionDimension { protected $columnName = 'fake_conversion_dimension_column'; - protected $columnType = 'INTEGER (10) DEFAULT 0'; + protected $columnType = 'VARCHAR (255) DEFAULT 0'; public function set($param, $value) { @@ -79,7 +79,7 @@ class ConversionDimensionTest extends IntegrationTestCase { $expected = array( 'log_conversion' => array( - "ADD COLUMN `fake_conversion_dimension_column` INTEGER (10) DEFAULT 0" + "ADD COLUMN `fake_conversion_dimension_column` VARCHAR (255) DEFAULT 0" ) ); @@ -90,7 +90,7 @@ class ConversionDimensionTest extends IntegrationTestCase { $expected = array( 'log_conversion' => array( - "MODIFY COLUMN `fake_conversion_dimension_column` INTEGER (10) DEFAULT 0" + "MODIFY COLUMN `fake_conversion_dimension_column` VARCHAR (255) DEFAULT 0" ) ); @@ -99,7 +99,7 @@ class ConversionDimensionTest extends IntegrationTestCase public function test_getVersion_shouldUseColumnTypeAsVersion() { - $this->assertEquals('INTEGER (10) DEFAULT 0', $this->dimension->getVersion()); + $this->assertEquals('VARCHAR (255) DEFAULT 0', $this->dimension->getVersion()); } public function test_getSegment_ShouldReturnConfiguredSegments() diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php index 505880b8a8..5642feefef 100644 --- a/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php +++ b/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php @@ -19,7 +19,7 @@ use Piwik\Tracker\Visitor; class FakeVisitDimension extends VisitDimension { protected $columnName = 'fake_visit_dimension_column'; - protected $columnType = 'INTEGER (10) DEFAULT 0'; + protected $columnType = 'VARCHAR (255) DEFAULT 0'; public $requiredFields = array(); public function set($param, $value) @@ -101,7 +101,7 @@ class VisitDimensionTest extends IntegrationTestCase { $expected = array( 'log_visit' => array( - "ADD COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" + "ADD COLUMN `fake_visit_dimension_column` VARCHAR (255) DEFAULT 0" ) ); @@ -112,10 +112,10 @@ class VisitDimensionTest extends IntegrationTestCase { $expected = array( 'log_visit' => array( - "ADD COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" + "ADD COLUMN `fake_visit_dimension_column` VARCHAR (255) DEFAULT 0" ), 'log_conversion' => array( - "ADD COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" + "ADD COLUMN `fake_visit_dimension_column` VARCHAR (255) DEFAULT 0" ) ); @@ -126,49 +126,35 @@ class VisitDimensionTest extends IntegrationTestCase { $expected = array( 'log_visit' => array( - "MODIFY COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" + "MODIFY COLUMN `fake_visit_dimension_column` VARCHAR (255) DEFAULT 0" ) ); - $this->assertEquals($expected, $this->dimension->update(array())); + $this->assertEquals($expected, $this->dimension->update()); } public function test_update_shouldUpdateLogVisitAndAddConversion_IfConversionMethodIsImplementedButNotInstalledYet() { $expected = array( 'log_visit' => array( - "MODIFY COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" + "MODIFY COLUMN `fake_visit_dimension_column` VARCHAR (255) DEFAULT 0" ), 'log_conversion' => array( - "ADD COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" + "ADD COLUMN `fake_visit_dimension_column` VARCHAR (255) DEFAULT 0" ) ); - $this->assertEquals($expected, $this->conversionDimension->update(array())); - } - - public function test_update_shouldUpdateLogVisitAndConversion_IfConversionMethodIsImplementedAndInstalled() - { - $expected = array( - 'log_visit' => array( - "MODIFY COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" - ), - 'log_conversion' => array( - "MODIFY COLUMN `fake_visit_dimension_column` INTEGER (10) DEFAULT 0" - ) - ); - - $this->assertEquals($expected, $this->conversionDimension->update(array('fake_visit_dimension_column' => array()))); + $this->assertEquals($expected, $this->conversionDimension->update()); } public function test_getVersion_shouldUseColumnTypeAsVersion() { - $this->assertEquals('INTEGER (10) DEFAULT 0', $this->dimension->getVersion()); + $this->assertEquals('VARCHAR (255) DEFAULT 0', $this->dimension->getVersion()); } public function test_getVersion_shouldIncludeConversionMethodIntoVersionNumber_ToMakeSureUpdateMethodWillBeTriggeredWhenPluginAddedConversionMethodInNewVersion() { - $this->assertEquals('INTEGER (10) DEFAULT 01', $this->conversionDimension->getVersion()); + $this->assertEquals('VARCHAR (255) DEFAULT 01', $this->conversionDimension->getVersion()); } public function test_getSegment_ShouldReturnNoSegments_IfNoneConfigured() diff --git a/tests/PHPUnit/Integration/SegmentTest.php b/tests/PHPUnit/Integration/SegmentTest.php index 20b23065db..0558d6a381 100644 --- a/tests/PHPUnit/Integration/SegmentTest.php +++ b/tests/PHPUnit/Integration/SegmentTest.php @@ -512,7 +512,7 @@ class SegmentTest extends IntegrationTestCase $this->assertEquals($this->removeExtraWhiteSpaces($expected), $this->removeExtraWhiteSpaces($query)); } - public function test_getSelectQuery_whenJoinLogLinkVisitActionOnActionOnVisit_WithSameTableAliasButDifferentJoin() + public function test_getSelectQuery_whenJoinLogLinkVisitActionOnActionOnVisit_WithNoTableAliasButDifferentJoin() { $actionType = 3; $idSite = 1; @@ -549,7 +549,7 @@ class SegmentTest extends IntegrationTestCase LEFT JOIN $logVisitTable AS log_visit ON log_visit.idvisit = log_link_visit_action.idvisit LEFT JOIN $logActionTable AS log_action - ON (log_link_visit_action.idaction_name = log_action.idaction AND log_link_visit_action.idaction_url = log_action.idaction) + ON log_link_visit_action.idaction_name = log_action.idaction WHERE ( log_link_visit_action.server_time >= ? AND log_link_visit_action.server_time <= ? AND log_link_visit_action.idsite = ? ) @@ -929,6 +929,99 @@ class SegmentTest extends IntegrationTestCase $this->assertEquals($this->removeExtraWhiteSpaces($expected), $this->removeExtraWhiteSpaces($query)); } + public function test_getSelectQuery_whenLimit_withCustomJoinsAndSameColumns() + { + $select = "log_action_visit_entry_idaction_name.name AS 'EntryPageTitle', log_action_idaction_event_action.name AS 'EventAction', count(distinct log_visit.idvisit) AS 'nb_uniq_visits', count(distinct log_visit.idvisitor) AS 'nb_uniq_visitors', sum(case log_visit.visit_total_actions when 1 then 1 when 0 then 1 else 0 end) AS 'bounce_count', sum(log_visit.visit_total_actions) AS 'sum_actions', sum(log_visit.visit_goal_converted) AS 'sum_visit_goal_converted'"; + $from = array('log_visit', array('table' => 'log_action', 'tableAlias' => 'log_action_visit_entry_idaction_name', 'joinOn' => 'log_visit.visit_entry_idaction_name = log_action_visit_entry_idaction_name.idaction'), 'log_link_visit_action', array('table' => 'log_action', 'tableAlias' => 'log_action_idaction_event_action', 'joinOn' => 'log_link_visit_action.idaction_event_action = log_action_idaction_event_action.idaction')); + $where = ''; + $bind = array(1); + + $segment = ''; + $segment = new Segment($segment, $idSites = array()); + + $orderBy = 'nb_uniq_visits, log_action_idaction_event_action.name'; + $groupBy = 'log_action_visit_entry_idaction_name.name, log_action_idaction_event_action.name'; + $limit = 33; + + $query = $segment->getSelectQuery($select, $from, $where, $bind, $orderBy, $groupBy, $limit); + + $expected = array( + "sql" => " + SELECT log_inner.name AS 'EntryPageTitle', log_inner.name02fd90a35677a359ea5611a4bc456a6f AS 'EventAction', count(distinct log_inner.idvisit) AS 'nb_uniq_visits', count(distinct log_inner.idvisitor) AS 'nb_uniq_visitors', sum(case log_inner.visit_total_actions when 1 then 1 when 0 then 1 else 0 end) AS 'bounce_count', sum(log_inner.visit_total_actions) AS 'sum_actions', sum(log_inner.visit_goal_converted) AS 'sum_visit_goal_converted' + FROM ( + SELECT log_action_visit_entry_idaction_name.name, log_action_idaction_event_action.name as name02fd90a35677a359ea5611a4bc456a6f, log_visit.idvisit, log_visit.idvisitor, log_visit.visit_total_actions, log_visit.visit_goal_converted + FROM log_visit AS log_visit + LEFT JOIN log_action AS log_action_visit_entry_idaction_name ON log_visit.visit_entry_idaction_name = log_action_visit_entry_idaction_name.idaction + LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit + LEFT JOIN log_action AS log_action_idaction_event_action ON log_link_visit_action.idaction_event_action = log_action_idaction_event_action.idaction + ORDER BY nb_uniq_visits, log_action_idaction_event_action.name LIMIT 0, 33 ) + AS log_inner + GROUP BY log_inner.name, log_inner.name02fd90a35677a359ea5611a4bc456a6f + ORDER BY nb_uniq_visits, log_inner.name02fd90a35677a359ea5611a4bc456a6f", + "bind" => array(1)); + + $this->assertEquals($this->removeExtraWhiteSpaces($expected), $this->removeExtraWhiteSpaces($query)); + } + + public function test_getSelectQuery_whenLimit_withCustomJoinsAndSameColumnsAndSimilarColumns() + { + $select = 'log_link_visit_action.idvisit, + log_visit.idvisit, + count(log_visit.idvisit) as numvisits, + count(distinct log_visit.idvisit ) as numvisitors, + log_visit.idvisitor, + log_action.name as url, + sum(log_link_visit_action.time_spent) as `13`, + sum(case log_visit.visit_total_actions when 1 then 1 when 0 then 1 else 0 end) as `6`'; + $from = array('log_visit', 'log_link_visit_action'); + $where = ''; + $bind = array(1); + + $segment = ''; + $segment = new Segment($segment, $idSites = array()); + + $orderBy = 'url, log_visit.idvisit'; + $groupBy = 'log_visit.idvisit, log_visit.idvisit , log_visit.idvisitor, log_visit.idvisitor , log_link_visit_action.idvisit'; + $limit = 33; + + $query = $segment->getSelectQuery($select, $from, $where, $bind, $orderBy, $groupBy, $limit); + + // should have replaced some idvisit columns but not idvisitor column + $expected = array( + "sql" => " + SELECT + log_inner.idvisit, + log_inner.idvisit5d489886e80b4258a9407b219a4e2811, + count(log_inner.idvisit5d489886e80b4258a9407b219a4e2811) as numvisits, + count(distinct log_inner.idvisit5d489886e80b4258a9407b219a4e2811 ) as numvisitors, + log_inner.idvisitor, + log_inner.name as url, + sum(log_inner.time_spent) as `13`, + sum(case log_inner.visit_total_actions when 1 then 1 when 0 then 1 else 0 end) as `6` + FROM + + ( + + SELECT + log_link_visit_action.idvisit, +log_visit.idvisit as idvisit5d489886e80b4258a9407b219a4e2811, +log_visit.idvisitor, +log_action.name, +log_link_visit_action.time_spent, +log_visit.visit_total_actions + FROM + log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit + ORDER BY + url, log_visit.idvisit LIMIT 0, 33 + ) AS log_inner + GROUP BY + log_inner.idvisit5d489886e80b4258a9407b219a4e2811, log_inner.idvisit5d489886e80b4258a9407b219a4e2811 , log_inner.idvisitor, log_inner.idvisitor , log_inner.idvisit + ORDER BY + url, log_inner.idvisit5d489886e80b4258a9407b219a4e2811", + "bind" => array(1)); + + $this->assertEquals($this->removeExtraWhiteSpaces($expected), $this->removeExtraWhiteSpaces($query)); + } public function test_getSelectQuery_whenLimitAndOffset_outerQueryShouldNotHaveOffset() { diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..98314b9ea4 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,27 @@ + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__VisitsSummary.get_range.xml new file mode 100644 index 0000000000..7ace3fcbe7 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerHour__VisitsSummary.get_range.xml @@ -0,0 +1,12 @@ + + + 18 + 18 + 18 + 18 + 0 + 1 + 100% + 1 + 0 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..6e7cfc1a1d --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,34 @@ + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__VisitsSummary.get_range.xml new file mode 100644 index 0000000000..f3bee672d6 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionServerMinute__VisitsSummary.get_range.xml @@ -0,0 +1,12 @@ + + + 35 + 95 + 35 + 18 + 27557 + 5 + 51% + 2.7 + 787 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_deviceType__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_deviceType__API.getSuggestedValuesForSegment.xml index 7b9c37df18..811b7dac21 100644 --- a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_deviceType__API.getSuggestedValuesForSegment.xml +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_deviceType__API.getSuggestedValuesForSegment.xml @@ -1,7 +1,14 @@ - Desktop - Smartphone - Phablet - Tablet + desktop + smartphone + tablet + feature phone + console + tv + car browser + smart display + camera + portable media player + phablet \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_interaction_position__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_interaction_position__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..c234bed59e --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_interaction_position__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_referrerType__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_referrerType__API.getSuggestedValuesForSegment.xml index 9b61eb17b1..000a8d45c4 100644 --- a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_referrerType__API.getSuggestedValuesForSegment.xml +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_referrerType__API.getSuggestedValuesForSegment.xml @@ -1,5 +1,7 @@ direct + website search + campaign \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEcommerceStatus__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEcommerceStatus__API.getSuggestedValuesForSegment.xml index 405fd9750c..5acd8f333f 100644 --- a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEcommerceStatus__API.getSuggestedValuesForSegment.xml +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEcommerceStatus__API.getSuggestedValuesForSegment.xml @@ -1,4 +1,7 @@ none + ordered + abandonedCart + orderedThenAbandonedCart \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..6e7cfc1a1d --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,34 @@ + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__VisitsSummary.get_range.xml new file mode 100644 index 0000000000..7ace3fcbe7 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitEndServerMinute__VisitsSummary.get_range.xml @@ -0,0 +1,12 @@ + + + 18 + 18 + 18 + 18 + 0 + 1 + 100% + 1 + 0 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..6e7cfc1a1d --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,34 @@ + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__VisitsSummary.get_range.xml new file mode 100644 index 0000000000..d8bcdace18 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitLocalMinute__VisitsSummary.get_range.xml @@ -0,0 +1,12 @@ + + + 0 + 0 + 0 + 0 + 0 + 0 + 0% + 0 + 0 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..6e7cfc1a1d --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,34 @@ + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__VisitsSummary.get_range.xml new file mode 100644 index 0000000000..7ace3fcbe7 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitServerMinute__VisitsSummary.get_range.xml @@ -0,0 +1,12 @@ + + + 18 + 18 + 18 + 18 + 0 + 1 + 100% + 1 + 0 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..98314b9ea4 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,27 @@ + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__VisitsSummary.get_range.xml new file mode 100644 index 0000000000..7ace3fcbe7 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerHour__VisitsSummary.get_range.xml @@ -0,0 +1,12 @@ + + + 18 + 18 + 18 + 18 + 0 + 1 + 100% + 1 + 0 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__API.getSuggestedValuesForSegment.xml new file mode 100644 index 0000000000..6e7cfc1a1d --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__API.getSuggestedValuesForSegment.xml @@ -0,0 +1,34 @@ + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__VisitsSummary.get_range.xml new file mode 100644 index 0000000000..7ace3fcbe7 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitStartServerMinute__VisitsSummary.get_range.xml @@ -0,0 +1,12 @@ + + + 18 + 18 + 18 + 18 + 0 + 1 + 100% + 1 + 0 + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitorType__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitorType__API.getSuggestedValuesForSegment.xml index 84613aaaf2..e598eaeee8 100644 --- a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitorType__API.getSuggestedValuesForSegment.xml +++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_visitorType__API.getSuggestedValuesForSegment.xml @@ -1,5 +1,6 @@ returningCustomer + returning new \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows__API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows__API.getProcessedReport_day.xml index b6cff4f6c8..66b9eb6bd3 100644 --- a/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows__API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows__API.getProcessedReport_day.xml @@ -8,7 +8,7 @@ Visits per server time VisitTime getVisitInformationPerServerTime - Server time + Server time - hour (End of visit) This graph shows what time it was in the <strong> server's time zone </strong> during the visits. Visits @@ -43,7 +43,7 @@ VisitTime_getVisitInformationPerServerTime - + Visits Unique visitors Actions diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml index f59cb9522a..442db1a9b3 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml @@ -8,7 +8,7 @@ Page titles Actions getPageTitles - Page Name + Page Title This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title. The percentage of visits that left the website after viewing this page. @@ -34,7 +34,7 @@ Actions_getPageTitles - + Exit rate diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumnsWithProcessedMetrics___API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumnsWithProcessedMetrics___API.getProcessedReport_day.xml index 92feaea19a..2137a5f645 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumnsWithProcessedMetrics___API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumnsWithProcessedMetrics___API.getProcessedReport_day.xml @@ -8,7 +8,7 @@ Visits per server time VisitTime getVisitInformationPerServerTime - Server time + Server time - hour (End of visit) This graph shows what time it was in the <strong> server's time zone </strong> during the visits. Visits @@ -28,7 +28,7 @@ VisitTime_getVisitInformationPerServerTime - + Visits Revenue diff --git a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml index a9e1f34081..33c6b4c63d 100644 --- a/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml @@ -8,7 +8,7 @@ Page titles Actions getPageTitles - Page Name + Page Title This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title. Pageviews @@ -38,7 +38,7 @@ Actions_getPageTitles - + Pageviews Bounce Rate diff --git a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_day.xml b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_day.xml index 649d127ab5..55f88165ef 100644 --- a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_day.xml +++ b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_day.xml @@ -190,7 +190,7 @@ 1 - Page Name + Page Title Pageviews Unique Pageviews diff --git a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_week.xml b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_week.xml index 573c484414..1da0cd6ff6 100644 --- a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_week.xml +++ b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitlesMulti__API.getRowEvolution_week.xml @@ -48,7 +48,7 @@ +100% - Page Name + Page Title Pageviews Unique Pageviews diff --git a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_day.xml b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_day.xml index 5b049977a4..b5a37adbc8 100644 --- a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_day.xml +++ b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_day.xml @@ -153,6 +153,6 @@ 2.8 - Page Name + Page Title \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_week.xml b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_week.xml index a4d4962bb2..a30e3f3a2e 100644 --- a/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_week.xml +++ b/tests/PHPUnit/System/expected/test_RowEvolution_pageTitles__API.getRowEvolution_week.xml @@ -89,6 +89,6 @@ -92% - Page Name + Page Title \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml index 3808a4f5b5..289959a721 100644 --- a/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml @@ -8,7 +8,7 @@ Page titles Actions getPageTitles - Page Name + Page Title This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title. Pageviews @@ -45,7 +45,7 @@ Actions_getPageTitles - + Pageviews Unique Pageviews Avg. time on page diff --git a/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_month.xml b/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_month.xml index f88c7b0657..a61bf4e2b8 100644 --- a/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_month.xml +++ b/tests/PHPUnit/System/expected/test_SiteSearch_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_month.xml @@ -8,7 +8,7 @@ Page titles Actions getPageTitles - Page Name + Page Title This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title. Pageviews @@ -45,7 +45,7 @@ Actions_getPageTitles - + Pageviews Unique Pageviews Avg. time on page diff --git a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml index ba0c0464ac..2ba4f93a54 100644 --- a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml @@ -8,7 +8,7 @@ Page titles Actions getPageTitles - Page Name + Page Title This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title. Pageviews @@ -46,7 +46,7 @@ Actions_getPageTitles - + Pageviews Unique Pageviews Avg. time on page diff --git a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_month.original.html b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_month.original.html index e30020a41d..5135698bdc 100644 --- a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_month.original.html +++ b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_month.original.html @@ -898,7 +898,7 @@
-  Operating System versions   +  Operating system version    Visits   @@ -2878,7 +2878,7 @@
-  Local time   +  Local time - hour (Start of visit)    Visits   @@ -3475,7 +3475,7 @@
-  Server time   +  Server time - hour (End of visit)    Visits   @@ -4898,7 +4898,7 @@
-  Page Name   +  Page Title    Pageviews   diff --git a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_month.original.html b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_month.original.html index 4ccc27edec..d503e5ebd0 100644 --- a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_month.original.html +++ b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_month.original.html @@ -849,7 +849,7 @@
-  Operating System versions   +  Operating system version    Visits   @@ -2703,7 +2703,7 @@
-  Local time   +  Local time - hour (Start of visit)    Visits   @@ -3293,7 +3293,7 @@
-  Server time   +  Server time - hour (End of visit)    Visits   @@ -4653,7 +4653,7 @@
-  Page Name   +  Page Title    Pageviews   diff --git a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_month.original.pdf b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_month.original.pdf index 4b292c91f7..130ab4d3a0 100644 Binary files a/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_month.original.pdf and b/tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_month.original.pdf differ diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getReportMetadata_day.xml b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getReportMetadata_day.xml index 50e1fd9532..fe04019899 100644 --- a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getReportMetadata_day.xml +++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getReportMetadata_day.xml @@ -332,7 +332,7 @@ Operating System versions DevicesDetection getOsVersions - Operating System versions + Operating system version Visits Unique visitors @@ -918,7 +918,7 @@ Visits per local time VisitTime getVisitInformationPerLocalTime - Local time + Local time - hour (Start of visit) This graph shows what time it was in the <strong> visitors' time zones </strong> during their visits. Visits @@ -959,7 +959,7 @@ Visits per server time VisitTime getVisitInformationPerServerTime - Server time + Server time - hour (End of visit) This graph shows what time it was in the <strong> server's time zone </strong> during the visits. Visits @@ -1265,7 +1265,7 @@ Page titles Actions getPageTitles - Page Name + Page Title This report contains information about the titles of the pages that have been visited. <br /> The page title is the HTML <title> Tag that most browsers show in their window title. Pageviews diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml index 326487de23..d72a0e6802 100644 --- a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml +++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml @@ -2,135 +2,86 @@ metric - Visit + Visitors + Actions In Visit + actions + + + metric + Visitors Days since first visit daysSinceFirstVisit metric - Visit + Visitors Days since last Ecommerce order daysSinceLastEcommerceOrder metric - Visit + Visitors Days since last visit daysSinceLastVisit metric - Visit - Number of Actions - actions + Visitors + Local time - minute (Start of visit) + visitLocalMinute + 0, 1, 2, 3, ..., 67, 57, 58, 59 metric - Visit + Visitors Number of Interactions interactions Any positive integer metric - Visit + Visitors Number of Internal Searches searches To select all visits who used internal Site Search, use: &segment=searches>0 metric - Visit + Visitors Number of visits visitCount metric - Visit + Visitors Total events events To select all visits who triggered an Event, use: &segment=events>0 metric - Visit + Visitors Visit Duration (in seconds) visitDuration metric - Visit + Visitors Visitor IP visitIp 13.54.122.1. </code>Select IP ranges with notation: <code>visitIp>13.54.122.0;visitIp<13.54.122.255 1 - - metric - Actions - Bandwidth - bandwidth - Any number in bytes, eg. 1000 - - - dimension - Visit Location - City - city - Sydney, Sao Paolo, Rome, etc. - - - dimension - Visit Location - Continent - continentCode - eur, asi, amc, amn, ams, afr, ant, oce - - - dimension - Visit Location - Country - countryCode - de, us, fr, in, es, etc. - - - dimension - Visit Location - Language - languageCode - de, fr, en-gb, zh-cn, etc. - - - dimension - Visit Location - Latitude - latitude - -33.578, 40.830, etc.<br/>You can select visitors within a lat/long range using &segment=lat>X;lat<Y;long>M;long<N. - dimension - Visit Location - Longitude - longitude - -70.664, 14.326, etc. - - - dimension - Visit Location - Region - regionCode - 01 02, OR, P8, etc.<br/>eg. region=A1;country=fr - - - dimension - Visit + Visitors Browser browserCode FF, IE, CH, SF, OP, etc. dimension - Visit + Visitors Browser engine browserEngine Trident, WebKit, Presto, Gecko, Blink, etc. @@ -138,63 +89,84 @@ dimension - Visit + Visitors Browser version browserVersion 1.0, 8.0, etc. dimension - Visit + Visitors Device brand deviceBrand 3Q, 4Good, Acer, Ainol, Airness, Airties, Alcatel, Allview, Altech UEC, Amazon, Amoi, Apple, Archos, Arnova, ARRIS, Asus, Audiovox, Avvio, Axxion, BangOlufsen, Barnes & Noble, BBK, Becker, Beetel, BenQ, BenQ-Siemens, Bird, Blackview, Blaupunkt, Blu, Bmobile, Boway, bq, Bravis, Brondi, Bush, Capitel, Captiva, Carrefour, Casio, Cat, Celkon, Changhong, Cherry Mobile, China Mobile, CnM, Coby Kyros, Compal, Compaq, ConCorde, Coolpad, Cowon, CreNova, Cricket, Crius Mea, Crosscall, Cube, CUBOT, Cyrus, Danew, Datang, Dbtel, Dell, Denver, Desay, DEXP, Dicam, Digma, DMM, DNS, DoCoMo, Doogee, Doov, Dopod, Dune HD, E-Boda, Easypix, EBEST, ECS, Elephone, Energy Sistem, Ericsson, Ericy, Eton, eTouch, Evertek, Evolveo, Explay, Ezio, Ezze, Fairphone, Fly, Foxconn, Freetel, Fujitsu, Garmin-Asus, Gateway, Gemini, Gigabyte, Gigaset, Gionee, GOCLEVER, Goly, Google, Gradiente, Grundig, Haier, Hasee, Hi-Level, Hisense, Homtom, Hosin, HP, HTC, Huawei, Humax, Hyrican, Hyundai, i-Joy, i-mate, i-mobile, iBall, iBerry, IconBIT, Ikea, iKoMo, iNew, Infinix, Inkti, Innostream, INQ, Intek, Intex, Inverto, iOcean, iTel, JAY-Tech, Jiayu, Jolla, K-Touch, Karbonn, Kazam, KDDI, Kiano, Kingsun, Komu, Konka, Konrow, Koobee, KOPO, Koridy, KT-Tech, Kumai, Kyocera, Landvo, Lanix, Lava, LCT, LeEco, Lenco, Lenovo, Le Pan, Lexibook, LG, Lingwin, Loewe, Logicom, LYF, M.T.T., Majestic, Manta Multimedia, Mecer, Mediacom, MediaTek, Medion, MEEG, Meizu, Memup, Metz, MEU, MicroMax, Microsoft, Mio, Mitsubishi, MIXC, MLLED, Mobistel, Modecom, Mofut, Motorola, Mpman, MSI, MyPhone, NEC, Neffos, Netgear, Newgen, Nexian, NextBook, NGM, Nikon, Nintendo, Noain, Nokia, Nomi, Nous, Nvidia, O2, Odys, Onda, OnePlus, OPPO, Opsson, Orange, Ouki, OUYA, Overmax, Oysters, Palm, Panasonic, Pantech, PEAQ, Pentagram, Philips, phoneOne, Pioneer, Ployer, Point of View, Polaroid, PolyPad, Pomp, Positivo, PPTV, Prestigio, ProScan, PULID, Qilive, QMobile, Qtek, Quechua, Ramos, RCA Tablets, Readboy, Rikomagic, RIM, Roku, Rover, Sagem, Samsung, Sanyo, Sega, Selevision, Sencor, Sendo, Senseit, SFR, Sharp, Siemens, Skyworth, Smart, Smartfren, Smartisan, Softbank, Sony, Sony Ericsson, Spice, Star, Stonex, Storex, Sumvision, SunVan, SuperSonic, Supra, Symphony, T-Mobile, TB Touch, TCL, TechniSat, TechnoTrend, Tecno Mobile, Telefunken, Telenor, Telit, Tesco, Tesla, teXet, ThL, Thomson, TIANYU, TiPhone, Tolino, Toplux, Toshiba, TrekStor, Trevi, Tunisie Telecom, Turbo-X, TVC, UMIDIGI, Uniscope, Unknown, Unowhy, UTStarcom, Vastking, Vertu, Vestel, Videocon, Videoweb, ViewSonic, Vitelcom, Vivo, Vizio, VK Mobile, Vodafone, Voto, Voxtel, Walton, Web TV, WellcoM, Wexler, Wiko, Wileyfox, Wolder, Wolfgang, Wonu, Woxter, Xiaomi, Xolo, Yarvik, Ytone, Yuandao, Yusun, Zeemi, Zen, Zonda, Zopo, ZTE dimension - Visit + Visitors Device type deviceType desktop, smartphone, tablet, feature phone, console, tv, car browser, smart display, camera, portable media player, phablet dimension - Visit - Local time + Visitors + Local time - hour (Start of visit) visitLocalHour 0, 1, 2, 3, ..., 20, 21, 22, 23 dimension - Visit + Visitors Operating system operatingSystemCode WIN, MAC, LIN, AND, IPD, etc. dimension - Visit + Visitors Operating system version operatingSystemVersion XP, 7, 2.3, 5.1, ... dimension - Visit + Visitors Resolution resolution 1280x1024, 800x600, etc. dimension - Visit - Server time + Visitors + Server time - hour (End of visit) visitServerHour 0, 1, 2, 3, ..., 20, 21, 22, 23 dimension - Visit + Visitors + Server time - hour (Start of visit) + visitStartServerHour + 0, 1, 2, 3, ..., 20, 21, 22, 23 + + + dimension + Visitors + Server time - minute (End of visit) + visitEndServerMinute + 0, 1, 2, 3, ..., 56, 57, 58, 59 + + + dimension + Visitors + Server time - minute (Start of visit) + visitStartServerMinute + 0, 1, 2, 3, ..., 56, 57, 58, 59 + + + dimension + Visitors User ID userId any non empty unique string identifying the user (such as an email address or a username). @@ -202,14 +174,14 @@ dimension - Visit + Visitors Visit Ecommerce status at the end of the visit visitEcommerceStatus none, ordered, abandonedCart, orderedThenAbandonedCart. For example, to select all visits that have made an Ecommerce order, the API request would contain "&segment=visitEcommerceStatus==ordered,visitEcommerceStatus==orderedThenAbandonedCart" dimension - Visit + Visitors Visit ID visitId Any integer. @@ -217,28 +189,28 @@ dimension - Visit + Visitors Visit converted a specific Goal Id visitConvertedGoalId 1, 2, 3, etc. dimension - Visit + Visitors Visit converted at least one Goal visitConverted 0, 1 dimension - Visit + Visitors Visit type visitorType new, returning, returningCustomer. For example, to select all visitors who have returned to the website, including those who have bought something in their previous visits, the API request would contain "&segment=visitorType==returning,visitorType==returningCustomer" dimension - Visit + Visitors Visitor ID visitorId 34c31e04394bdc63 - any 16 Hexadecimal chars ID, which can be fetched using the Tracking API function getVisitorId() @@ -246,49 +218,52 @@ dimension - Referrers - Keyword - referrerKeyword - Encoded%20Keyword, keyword + Visit Location + City + city + Sydney, Sao Paolo, Rome, etc. dimension - Referrers - Referrer Name - referrerName - twitter.com, www.facebook.com, Bing, Google, Yahoo, CampaignName + Visit Location + Continent + continentCode + eur, asi, amc, amn, ams, afr, ant, oce dimension - Referrers - Referrer Type - referrerType - direct, search, website, campaign + Visit Location + Country + countryCode + de, us, fr, in, es, etc. dimension - Referrers - Referrer URL - referrerUrl - http%3A%2F%2Fwww.example.org%2Freferer-page.htm + Visit Location + Language + languageCode + de, fr, en-gb, zh-cn, etc. dimension - Events - Event Action - eventAction + Visit Location + Latitude + latitude + -33.578, 40.830, etc.<br/>You can select visitors within a lat/long range using &segment=lat>X;lat<Y;long>M;long<N. dimension - Events - Event Category - eventCategory + Visit Location + Longitude + longitude + -70.664, 14.326, etc. dimension - Events - Event Name - eventName + Visit Location + Region + regionCode + 01 02, OR, P8, etc.<br/>eg. region=A1;country=fr dimension @@ -462,6 +437,13 @@ Custom Variable value 5 (scope visit) customVariableValue5 + + metric + Actions + Bandwidth + bandwidth + Any number in bytes, eg. 1000 + dimension Actions @@ -553,7 +535,7 @@ dimension Actions - Page Name + Page Title pageTitle @@ -563,4 +545,63 @@ pageUrl All these segments must be URL encoded, for example: http%3A%2F%2Fexample.com%2Fpath%2Fpage%3Fquery + + dimension + Actions + Server time - hour + actionServerHour + + + dimension + Actions + Server time - minute + actionServerMinute + 0, 1, 2, 3, ..., 56, 57, 58, 59 + + + dimension + Events + Event Action + eventAction + + + dimension + Events + Event Category + eventCategory + + + dimension + Events + Event Name + eventName + + + dimension + Referrers + Keyword + referrerKeyword + Encoded%20Keyword, keyword + + + dimension + Referrers + Referrer Name + referrerName + twitter.com, www.facebook.com, Bing, Google, Yahoo, CampaignName + + + dimension + Referrers + Referrer Type + referrerType + direct, search, website, campaign + + + dimension + Referrers + Referrer URL + referrerUrl + http%3A%2F%2Fwww.example.org%2Freferer-page.htm + \ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml index 6c39c185b3..f4fea49b13 100755 --- a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml +++ b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml @@ -8,7 +8,7 @@ Visits per server time VisitTime getVisitInformationPerServerTime - Server time + Server time - hour (End of visit) This graph shows what time it was in the <strong> server's time zone </strong> during the visits. Visits @@ -43,7 +43,7 @@ VisitTime_getVisitInformationPerServerTime - + Visits Unique visitors Actions diff --git a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_week.original.html b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_week.original.html index 03c3ee692b..a6c31c80a0 100644 --- a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_week.original.html +++ b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_and_graph__ScheduledReports.generateReport_week.original.html @@ -1018,7 +1018,7 @@
-  Operating System versions   +  Operating system version    Visits   @@ -2733,7 +2733,7 @@
-  Local time   +  Local time - hour (Start of visit)    Visits   @@ -3330,7 +3330,7 @@
-  Server time   +  Server time - hour (End of visit)    Visits   @@ -4591,7 +4591,7 @@
-  Page Name   +  Page Title    Pageviews   diff --git a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_week.original.html b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_week.original.html index 6177dda553..0a0b0ba34f 100644 --- a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_week.original.html +++ b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_week.original.html @@ -962,7 +962,7 @@
-  Operating System versions   +  Operating system version    Visits   @@ -2551,7 +2551,7 @@
-  Local time   +  Local time - hour (Start of visit)    Visits   @@ -3141,7 +3141,7 @@
-  Server time   +  Server time - hour (End of visit)    Visits   @@ -4339,7 +4339,7 @@
-  Page Name   +  Page Title    Pageviews   diff --git a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_week.original.pdf b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_week.original.pdf index a7165b7710..fa8a66e86f 100644 Binary files a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_week.original.pdf and b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_pdf_tables_only__ScheduledReports.generateReport_week.original.pdf differ diff --git a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php index 8e1ead3aec..0f75716c9c 100644 --- a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php +++ b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php @@ -255,6 +255,7 @@ class JoinGeneratorTest extends \PHPUnit_Framework_TestCase usort($tables, array($generator, 'sortTablesForJoin')); $expected = array( + 'log_link_visit_action', array ( 'table' => 'log_link_visit_action', 'tableAlias' => 'log_link_visit_action_foo', @@ -265,7 +266,6 @@ class JoinGeneratorTest extends \PHPUnit_Framework_TestCase 'tableAlias' => 'log_action_foo', 'joinOn' => 'log_link_visit_action_foo.idaction_url = log_action_foo.idaction', ), - 'log_link_visit_action', 'log_action', ); @@ -293,6 +293,42 @@ class JoinGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $tables); } + public function test_sortTablesForJoin_shouldSortTablesWithCustomJoinRequiringEachOther2() + { + $tables = array( + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_visit_entry_idaction_name', + 'joinOn' => "log_visit.visit_entry_idaction_name = log_action_visit_entry_idaction_name.idaction" + ), + 'log_link_visit_action', + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_idaction_event_action', + 'joinOn' => "log_link_visit_action.idaction_event_action = log_action_idaction_event_action.idaction" + ) + ); + + $generator = $this->makeGenerator($tables); + usort($tables, array($generator, 'sortTablesForJoin')); + + $expected = array( + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_visit_entry_idaction_name', + 'joinOn' => "log_visit.visit_entry_idaction_name = log_action_visit_entry_idaction_name.idaction" + ), + 'log_link_visit_action', + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_idaction_event_action', + 'joinOn' => "log_link_visit_action.idaction_event_action = log_action_idaction_event_action.idaction" + ) + ); + + $this->assertEquals($expected, $tables); + } + private function generate($tables) { $generator = $this->makeGenerator($tables); diff --git a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php index 050009d6df..8291db620a 100644 --- a/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php +++ b/tests/PHPUnit/Unit/DataTable/Filter/AddSegmentFilterBySegmentValueTest.php @@ -80,14 +80,6 @@ class AddSegmentBySegmentValueTest extends \PHPUnit_Framework_TestCase $this->assertSegment('city==mytest', $row); } - public function test_filter_shouldUseTheFirstSegment_IfAReportHasMultiple() - { - $report = new GetCountry(); - $this->assertCount(2, $report->getDimension()->getSegments()); - - $this->assertSegmentForSegmentValueAndReport($report, $segmentValue = 'existing', 'countryCode==existing'); - } - public function test_filter_shouldNotGenerateASegment_IfReportHasNoDimension() { $report = new Get(); // VisitsSummary.get has no dimension diff --git a/tests/PHPUnit/Unit/DeprecatedMethodsTest.php b/tests/PHPUnit/Unit/DeprecatedMethodsTest.php index bea7551e1e..a0cd9905f0 100644 --- a/tests/PHPUnit/Unit/DeprecatedMethodsTest.php +++ b/tests/PHPUnit/Unit/DeprecatedMethodsTest.php @@ -81,6 +81,9 @@ class DeprecatedMethodsTest extends \PHPUnit_Framework_TestCase $this->assertDeprecatedMethodIsRemovedInPiwik4('Piwik\Updates', 'update'); $this->assertDeprecatedMethodIsRemovedInPiwik4('Piwik\Updates', 'getMigrationQueries'); $this->assertDeprecatedMethodIsRemovedInPiwik4('Piwik\Updater', 'executeMigrationQueries'); + + // THIS IS A REMINDER FOR PIWIK 4: We need to rename getColumnType() to getDbColumnType() and $columnType to $dbColumnType + $this->assertDeprecatedMethodIsRemovedInPiwik4('Piwik\Columns\Dimension', 'getType'); } -- cgit v1.2.3