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:
authordizzy <diosmosis@users.noreply.github.com>2021-05-23 23:38:01 +0300
committerGitHub <noreply@github.com>2021-05-23 23:38:01 +0300
commitcdbb35347d5a5cd75cde3f32ee1c7192354e306a (patch)
tree1aaf410839969fa3b40bb70c8d8aed10baaa9e3b /tests/PHPUnit/Integration/SegmentTest.php
parent1956e75c66d9acaa4df3b30ad179278d46bbb816 (diff)
Use originalString when returning the Segment definition string (#17610)
Diffstat (limited to 'tests/PHPUnit/Integration/SegmentTest.php')
-rw-r--r--tests/PHPUnit/Integration/SegmentTest.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/SegmentTest.php b/tests/PHPUnit/Integration/SegmentTest.php
index 75c7545ed2..9e9662aefe 100644
--- a/tests/PHPUnit/Integration/SegmentTest.php
+++ b/tests/PHPUnit/Integration/SegmentTest.php
@@ -16,6 +16,7 @@ use Piwik\Container\StaticContainer;
use Piwik\Date;
use Piwik\Db;
use Piwik\Http;
+use Piwik\Plugins\SegmentEditor\API;
use Piwik\Segment;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\Mock\FakeAccess;
@@ -48,6 +49,24 @@ class SegmentTest extends IntegrationTestCase
self::$fixture->getTestEnvironment()->save();
}
+ public function test_getHash_returnsCorrectHashWhenDefinitionIsFromGetStringFromSegmentTableDefinition()
+ {
+ // definition is encoded as it would be in the URL
+ $idSegment = API::getInstance()->add('test segment', 'pageUrl%3D%3Dhttps%25253A%25252F%25252Fserenity.org%25252Fparticipate%25252F');
+ $segmentInfo = API::getInstance()->get($idSegment);
+
+ $segment = new Segment($segmentInfo['definition'], []);
+
+ $hash = $segment->getHash();
+ $this->assertEquals($segmentInfo['hash'], $hash);
+
+ $segmentStringFromObject = $segment->getOriginalString();
+ $segment2 = new Segment($segmentStringFromObject, []);
+
+ $hash = $segment2->getHash();
+ $this->assertEquals($segmentInfo['hash'], $hash);
+ }
+
static public function removeExtraWhiteSpaces($valueToFilter)
{
if (is_array($valueToFilter)) {