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/Tour/tests/System/ConsentManagerDetectionTest.php')
-rw-r--r--plugins/Tour/tests/System/ConsentManagerDetectionTest.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/Tour/tests/System/ConsentManagerDetectionTest.php b/plugins/Tour/tests/System/ConsentManagerDetectionTest.php
new file mode 100644
index 0000000000..0f09ae02ac
--- /dev/null
+++ b/plugins/Tour/tests/System/ConsentManagerDetectionTest.php
@@ -0,0 +1,53 @@
+<?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\Tour\tests\System;
+
+use Piwik\Plugins\Tour\Engagement\ChallengeSetupConsentManager;
+use Piwik\SiteContentDetector;
+use Piwik\Tests\Framework\TestCase\SystemTestCase;
+
+/**
+ * @group ConsentManagerDetectionTest
+ * @group TourTest
+ * @group Plugins
+ */
+class ConsentManagerDetectionTest extends SystemTestCase
+{
+
+ public function setUp(): void
+ {
+ parent::setUp();
+ }
+
+ public function test_detectConsentManager_disableWhenNotDetected()
+ {
+ $siteData = '';
+ $challenge = new ChallengeSetupConsentManager(new SiteContentDetector(), $siteData);
+ $this->assertTrue($challenge->isDisabled());
+ }
+
+ public function test_detectConsentManager_detectedButNotConnected()
+ {
+ $siteData = '<html><head><script src="https://osano.com/uhs9879874hthg.js"></script></head><body>A site</body></html>';
+ $challenge = new ChallengeSetupConsentManager(new SiteContentDetector(), $siteData);
+ $this->assertFalse($challenge->isDisabled());
+ $this->assertFalse($challenge->isCompleted());
+ $this->assertEquals('osano', $challenge->getConsentManagerId());
+ }
+
+ public function test_detectConsentManager_detectedAndConnected()
+ {
+ $siteData = "<html><head><script src='https://osano.com/uhs9879874hthg.js'></script><script>Osano.cm.addEventListener('osano-cm-consent-changed', (change) => { console.log('cm-change'); consentSet(change); });</script></head><body>A site</body></html>";
+ $challenge = new ChallengeSetupConsentManager(new SiteContentDetector(), $siteData);
+ $this->assertFalse($challenge->isDisabled());
+ $this->assertTrue($challenge->isCompleted());
+ $this->assertEquals('osano', $challenge->getConsentManagerId());
+ }
+
+}