Enhance EnableListenerCheckerTest with support for matomo listener

This commit is contained in:
Alejandro Celaya 2023-11-16 09:24:52 +01:00
parent f88d57b2b6
commit a7ed14a1c9

View File

@ -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,