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/Unit/DataTable/Filter/AddSegmentMetadataTest.php')
m---------plugins/CustomDimensions0
-rw-r--r--plugins/CustomDimensions/tests/Unit/DataTable/Filter/AddSegmentMetadataTest.php47
2 files changed, 47 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions
deleted file mode 160000
-Subproject 318661a2fb1ef3b3e5d6d999ae8b9628cb5a113
diff --git a/plugins/CustomDimensions/tests/Unit/DataTable/Filter/AddSegmentMetadataTest.php b/plugins/CustomDimensions/tests/Unit/DataTable/Filter/AddSegmentMetadataTest.php
new file mode 100644
index 0000000000..8ed19c4811
--- /dev/null
+++ b/plugins/CustomDimensions/tests/Unit/DataTable/Filter/AddSegmentMetadataTest.php
@@ -0,0 +1,47 @@
+<?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\Unit\DataTable\Filter;
+use Piwik\DataTable;
+use Piwik\DataTable\Row;
+use Piwik\Plugins\CustomDimensions\Archiver;
+
+/**
+ * @group CustomDimensions
+ * @group AddSegmentMetadataTest
+ * @group AddSegmentMetadata
+ * @group Plugins
+ */
+class AddSegmentMetadataTest extends \PHPUnit\Framework\TestCase
+{
+ private $filter = 'Piwik\Plugins\CustomDimensions\DataTable\Filter\AddSegmentMetadata';
+
+ public function test_filter()
+ {
+ $dataTable = new DataTable();
+ $dataTable->addRowsFromArray(array(
+ array(Row::COLUMNS => array('label' => 'val1', 'nb_visits' => 120)), // normal case
+ array(Row::COLUMNS => array('nb_visits' => 90)), // no label should not add segment metadata
+ array(Row::COLUMNS => array('label' => 'val2 5w รถ?', 'nb_visits' => 99)), // should encode label
+ array(Row::COLUMNS => array('label' => Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED, 'nb_visits' => 99)) // should set no label
+ ));
+
+ $dataTable->filter($this->filter, array($idDimension = 5));
+
+ $metadata = $dataTable->getRowsMetadata('segment');
+
+ $expected = array(
+ 'dimension5==val1',
+ false,
+ 'dimension5==val2+5w+%C3%B6%3F',
+ 'dimension5=='
+ );
+ $this->assertSame($expected, $metadata);
+ }
+
+}