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/DataTable/Filter/RemoveUserIfNeededTest.php')
m---------plugins/CustomDimensions0
-rw-r--r--plugins/CustomDimensions/tests/Integration/DataTable/Filter/RemoveUserIfNeededTest.php62
2 files changed, 62 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions
deleted file mode 160000
-Subproject 318661a2fb1ef3b3e5d6d999ae8b9628cb5a113
diff --git a/plugins/CustomDimensions/tests/Integration/DataTable/Filter/RemoveUserIfNeededTest.php b/plugins/CustomDimensions/tests/Integration/DataTable/Filter/RemoveUserIfNeededTest.php
new file mode 100644
index 0000000000..1aacb27ad1
--- /dev/null
+++ b/plugins/CustomDimensions/tests/Integration/DataTable/Filter/RemoveUserIfNeededTest.php
@@ -0,0 +1,62 @@
+<?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\Integration\DataTable\Filter;
+
+use Piwik\DataTable;
+use Piwik\DataTable\Row;
+use Piwik\Metrics;
+use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+
+/**
+ * @group CustomDimensions
+ * @group DimensionTest
+ * @group Dimension
+ * @group Dao
+ * @group Plugins
+ */
+class RemoveUserIfNeededTest extends IntegrationTestCase
+{
+ private $filter = 'Piwik\Plugins\CustomDimensions\DataTable\Filter\RemoveUserIfNeeded';
+
+ public function setUp(): void
+ {
+ parent::setUp();
+
+ Fixture::createWebsite('2010-01-01 00:00:00');
+ }
+
+ public function test_filter_shouldNotRemoveColumn_IfThereIsAValueInTableForNbUsers()
+ {
+ $columns = $this->filterTable($withUser = 5);
+
+ $this->assertSame(array(0, false, 5), $columns);
+ }
+
+ public function test_filter_withoutUsers_shouldRemoveColumn()
+ {
+ $columns = $this->filterTable($withUser = 0);
+ $this->assertSame(array(false, false, false), $columns);
+ }
+
+ private function filterTable($withUser = 5)
+ {
+ $dataTable = new DataTable();
+ $dataTable->addRowsFromArray(array(
+ array(Row::COLUMNS => array('label' => 'val1', Metrics::INDEX_NB_USERS => 0)),
+ array(Row::COLUMNS => array('label' => 'val2')),
+ array(Row::COLUMNS => array('label' => 'val2 5w รถ?', Metrics::INDEX_NB_USERS => $withUser))
+ ));
+
+ $dataTable->filter($this->filter, array($idSite = 1, $period = 'day', $date = 'today'));
+
+ return $dataTable->getColumn(Metrics::INDEX_NB_USERS);
+ }
+
+}