Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CustomDimensions/tests/Integration/SegmentTest.php')
m---------plugins/CustomDimensions0
-rw-r--r--plugins/CustomDimensions/tests/Integration/SegmentTest.php46
2 files changed, 46 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions
deleted file mode 160000
-Subproject 318661a2fb1ef3b3e5d6d999ae8b9628cb5a113
diff --git a/plugins/CustomDimensions/tests/Integration/SegmentTest.php b/plugins/CustomDimensions/tests/Integration/SegmentTest.php
new file mode 100644
index 0000000000..901991becb
--- /dev/null
+++ b/plugins/CustomDimensions/tests/Integration/SegmentTest.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\CustomDimensions\tests;
+
+use Piwik\Plugins\CustomDimensions\API;
+use Piwik\Segment;
+use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+
+class SegmentTest extends IntegrationTestCase
+{
+ public function setUp(): void
+ {
+ parent::setUp();
+
+ $idSite = Fixture::createWebsite('2012-02-03');
+ API::getInstance()->configureNewCustomDimension($idSite, 'test dim', 'visit', 1);
+ }
+
+ public function test_Segment_CanSeeCustomDimensionSegments()
+ {
+ $select = 'log_visit.idvisit';
+ $from = 'log_visit';
+
+ $segmentStr = 'dimension1==5';
+ $segment = new Segment($segmentStr, [1]);
+
+ /** @var array $query */
+ $query = $segment->getSelectQuery($select, $from);
+ $query['sql'] = trim(preg_replace('/\s+/', ' ', $query['sql']));
+
+ $expectedQuery = [
+ 'sql' => 'SELECT log_visit.idvisit FROM log_visit AS log_visit WHERE log_visit.custom_dimension_1 = ?',
+ 'bind' => [
+ 5,
+ ],
+ ];
+ $this->assertEquals($expectedQuery, $query);
+ }
+} \ No newline at end of file