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/SegmentEditor/tests')
-rw-r--r--plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php5
-rw-r--r--plugins/SegmentEditor/tests/System/ApiTest.php33
2 files changed, 36 insertions, 2 deletions
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
index ec594117a9..09430ca9be 100644
--- a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
+++ b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
@@ -72,9 +72,10 @@ class SegmentEditorTest extends IntegrationTestCase
$segment = API::getInstance()->get($idSegment);
unset($segment['ts_created']);
$expected = array(
- 'idsegment' => 1,
+ 'idsegment' => '1',
'name' => $name,
'definition' => $definition,
+ 'hash' => md5($definition),
'login' => 'superUserLogin',
'enable_all_users' => '0',
'enable_only_idsite' => '0',
@@ -104,6 +105,7 @@ class SegmentEditorTest extends IntegrationTestCase
'idsegment' => '1',
'name' => $name,
'definition' => $definition,
+ 'hash' => md5($definition),
'login' => 'superUserLogin',
'enable_all_users' => '1',
'enable_only_idsite' => '1',
@@ -145,6 +147,7 @@ class SegmentEditorTest extends IntegrationTestCase
'idsegment' => $idSegment2,
'name' => 'NEW name',
'definition' => 'searches==0',
+ 'hash' => md5('searches==0'),
'enable_only_idsite' => '0',
'enable_all_users' => '0',
'auto_archive' => '1',
diff --git a/plugins/SegmentEditor/tests/System/ApiTest.php b/plugins/SegmentEditor/tests/System/ApiTest.php
index 0ae9dea78c..2b8d881490 100644
--- a/plugins/SegmentEditor/tests/System/ApiTest.php
+++ b/plugins/SegmentEditor/tests/System/ApiTest.php
@@ -62,4 +62,35 @@ class ApiTest extends SystemTestCase
$this->assertEquals($segmentApiHash, $segmentDefinitionHash);
}
-} \ No newline at end of file
+
+ /**
+ * @dataProvider definitionsDataProvider
+ */
+ public function test_generatedSegmentHash($definition)
+ {
+ Fixture::createWebsite('2020-03-03 00:00:00');
+
+ Config::getInstance()->General['enable_browser_archiving_triggering'] = 0;
+ self::$fixture->getTestEnvironment()->overrideConfig('General', 'enable_browser_archiving_triggering', 0);
+ self::$fixture->getTestEnvironment()->save();
+
+ $idSegment = SegmentEditorApi::getInstance()->add('test segment', $definition, 1, 1, 1);
+ $segment = SegmentEditorApi::getInstance()->get($idSegment);
+
+ $hash = $segment['hash'];
+ $generatedHash = md5(urldecode($segment['definition']));
+
+ $this->assertEquals($generatedHash, $hash);
+ }
+
+ public function definitionsDataProvider()
+ {
+ return [
+ ['pageUrl=@%252F1'],
+ ['actions>=1'],
+ ['operatingSystemName==Ubuntu;browserName==Firefox'],
+ ['pageUrl==https%253A%252F%252Fmatomo.org%252Fpricing%252F'],
+ ['visitIp>=80.229.0.0;visitIp<=80.229.255.255'],
+ ];
+ }
+}