<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CoreBundle\Tests\EventListener;

use Ferienpass\CoreBundle\EventListener\RateLimiterListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\KernelEvents;

final class RateLimiterListenerTest extends TestCase
{
    public function testGetSubscribedEventsIncludesKernelRequest(): void
    {
        $events = RateLimiterListener::getSubscribedEvents();

        self::assertArrayHasKey(KernelEvents::REQUEST, $events);
    }

    public function testSubscribedEventHandlerIsOnKernelRequest(): void
    {
        $events = RateLimiterListener::getSubscribedEvents();

        // Handler must reference onKernelRequest method
        $handler = $events[KernelEvents::REQUEST];
        self::assertStringContainsString('onKernelRequest', (string) (\is_array($handler) ? $handler[0] : $handler));
    }
}
