From a7ed14a1c9e8c98ed1409a4f3ea82e314438fcf9 Mon Sep 17 00:00:00 2001
From: Alejandro Celaya <alejandrocelaya@gmail.com>
Date: Thu, 16 Nov 2023 09:24:52 +0100
Subject: [PATCH] Enhance EnableListenerCheckerTest with support for matomo
 listener

---
 .../Helper/EnabledListenerCheckerTest.php      | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/module/Core/test/EventDispatcher/Helper/EnabledListenerCheckerTest.php b/module/Core/test/EventDispatcher/Helper/EnabledListenerCheckerTest.php
index 44ef500c..00f78fe4 100644
--- a/module/Core/test/EventDispatcher/Helper/EnabledListenerCheckerTest.php
+++ b/module/Core/test/EventDispatcher/Helper/EnabledListenerCheckerTest.php
@@ -9,6 +9,7 @@ use PHPUnit\Framework\Attributes\Test;
 use PHPUnit\Framework\TestCase;
 use Shlinkio\Shlink\Common\Mercure\MercureOptions;
 use Shlinkio\Shlink\Core\EventDispatcher\Helper\EnabledListenerChecker;
+use Shlinkio\Shlink\Core\EventDispatcher\Matomo\SendVisitToMatomo;
 use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyNewShortUrlToMercure;
 use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyVisitToMercure;
 use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToWebHooks;
@@ -27,7 +28,7 @@ class EnabledListenerCheckerTest extends TestCase
     #[Test, DataProvider('provideListeners')]
     public function syncListenersAreRegisteredByDefault(string $listener): void
     {
-        self::assertTrue($this->checker()->shouldRegisterListener('', $listener, false));
+        self::assertTrue($this->checker()->shouldRegisterListener(event: '', listener: $listener, isAsync: false));
     }
 
     public static function provideListeners(): iterable
@@ -39,6 +40,7 @@ class EnabledListenerCheckerTest extends TestCase
             [NotifyNewShortUrlToRedis::class],
             [NotifyVisitToMercure::class],
             [NotifyNewShortUrlToMercure::class],
+            [SendVisitToMatomo::class],
             [NotifyVisitToWebHooks::class],
             [UpdateGeoLiteDb::class],
         ];
@@ -114,6 +116,18 @@ class EnabledListenerCheckerTest extends TestCase
             UpdateGeoLiteDb::class => true,
             'unknown' => false,
         ]];
+        yield 'Matomo' => [self::checker(matomoEnabled: true), [
+            NotifyVisitToRabbitMq::class => false,
+            NotifyNewShortUrlToRabbitMq::class => false,
+            NotifyVisitToRedis::class => false,
+            NotifyNewShortUrlToRedis::class => false,
+            NotifyVisitToMercure::class => false,
+            NotifyNewShortUrlToMercure::class => false,
+            SendVisitToMatomo::class => true,
+            NotifyVisitToWebHooks::class => false,
+            UpdateGeoLiteDb::class => false,
+            'unknown' => false,
+        ]];
         yield 'All disabled' => [self::checker(), [
             NotifyVisitToRabbitMq::class => false,
             NotifyNewShortUrlToRabbitMq::class => false,
@@ -131,6 +145,7 @@ class EnabledListenerCheckerTest extends TestCase
             mercureEnabled: true,
             webhooksEnabled: true,
             geoLiteEnabled: true,
+            matomoEnabled: true,
         ), [
             NotifyVisitToRabbitMq::class => true,
             NotifyNewShortUrlToRabbitMq::class => true,
@@ -138,6 +153,7 @@ class EnabledListenerCheckerTest extends TestCase
             NotifyNewShortUrlToRedis::class => true,
             NotifyVisitToMercure::class => true,
             NotifyNewShortUrlToMercure::class => true,
+            SendVisitToMatomo::class => true,
             NotifyVisitToWebHooks::class => true,
             UpdateGeoLiteDb::class => true,
             'unknown' => false,