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:
authorZoltan Flamis <flamisz@gmail.com>2021-03-29 06:42:17 +0300
committerGitHub <noreply@github.com>2021-03-29 06:42:17 +0300
commitd26f304da8d0a0f995abafc11501676dad6be846 (patch)
tree64e477e592c947fbcf54dcfcd120b6461381ca4e /plugins/SitesManager/tests
parent8402837f40dbc1e35ab3012dc28a37bbf3e66828 (diff)
Improve no data tracked yet screen (#17367)4.3.0-b2
* wip * wip * wip * wip * wip * tabs and basic structure * wip * wip * tagmanager tab * fix send email link * use element, add comment * use widget loader * test wip * site type guesser class * add sharepoint guess * catch http request exception * update ui test images * cache site types and gtm * cache DI * fill untranslated text Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'plugins/SitesManager/tests')
-rw-r--r--plugins/SitesManager/tests/Unit/GuessSiteTypeAndGtmTest.php102
1 files changed, 102 insertions, 0 deletions
diff --git a/plugins/SitesManager/tests/Unit/GuessSiteTypeAndGtmTest.php b/plugins/SitesManager/tests/Unit/GuessSiteTypeAndGtmTest.php
new file mode 100644
index 0000000000..66045cc909
--- /dev/null
+++ b/plugins/SitesManager/tests/Unit/GuessSiteTypeAndGtmTest.php
@@ -0,0 +1,102 @@
+<?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\SitesManager\tests\Unit;
+
+use Piwik\Plugins\SitesManager\GtmSiteTypeGuesser;
+use Piwik\Plugins\SitesManager\SitesManager;
+
+/**
+ * @group SitesManager
+ * @group GtmSiteTypeGuesserTest
+ * @group Plugins
+ */
+class GtmSiteTypeGuesserTest extends \PHPUnit\Framework\TestCase
+{
+ /**
+ * @var GtmSiteTypeGuesser
+ */
+ private $guesser;
+
+ public function setUp(): void
+ {
+ parent::setUp();
+
+ $this->guesser = new GtmSiteTypeGuesser();
+ }
+
+ public function test_site_type_unknown_if_response_false()
+ {
+ $this->assertEquals(SitesManager::SITE_TYPE_UNKNOWN, $this->guesser->guessSiteTypeFromResponse(false));
+ }
+
+ public function test_gtm_is_false_if_response_false()
+ {
+ $this->assertFalse($this->guesser->guessGtmFromResponse(false));
+ }
+
+ public function test_gtm_is_true()
+ {
+ $response = [
+ 'status' => 200,
+ 'headers' => [],
+ 'data' => 'it contains gtm.start somewhere'
+ ];
+
+ $this->assertTrue($this->guesser->guessGtmFromResponse($response));
+ }
+
+ /**
+ * @dataProvider responseProvider
+ */
+ public function test_site_types_by_response($expected, $response)
+ {
+ $this->assertEquals($expected, $this->guesser->guessSiteTypeFromResponse($response));
+ }
+
+ public function responseProvider()
+ {
+ return [
+ [SitesManager::SITE_TYPE_UNKNOWN, [
+ 'status' => 200,
+ 'headers' => [],
+ 'data' => 'nothing special'
+ ]],
+ [SitesManager::SITE_TYPE_SHOPIFY, [
+ 'status' => 200,
+ 'headers' => [],
+ 'data' => 'contains Shopify.theme text'
+ ]],
+ [SitesManager::SITE_TYPE_WORDPRESS, [
+ 'status' => 200,
+ 'headers' => [],
+ 'data' => 'contains /wp-content text'
+ ]],
+ [SitesManager::SITE_TYPE_WIX, [
+ 'status' => 200,
+ 'headers' => [],
+ 'data' => 'contains X-Wix-Published-Version text'
+ ]],
+ [SitesManager::SITE_TYPE_SQUARESPACE, [
+ 'status' => 200,
+ 'headers' => [],
+ 'data' => 'contains <!-- This is Squarespace. --> text'
+ ]],
+ [SitesManager::SITE_TYPE_SHAREPOINT, [
+ 'status' => 200,
+ 'headers' => [],
+ 'data' => 'contains content="Microsoft SharePoint text'
+ ]],
+ [SitesManager::SITE_TYPE_JOOMLA, [
+ 'status' => 200,
+ 'headers' => ['expires' => 'Wed, 17 Aug 2005 00:00:00 GMT'],
+ 'data' => 'nothing special'
+ ]],
+ ];
+ }
+}