<?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\CmsBundle\Tests\NotificationHandler;

use Ferienpass\CmsBundle\Message\LoginLinkRequested;
use Ferienpass\CmsBundle\NotificationHandler\LoginLink;
use Ferienpass\CoreBundle\Notification\UserLoginLinkNotification;
use Ferienpass\CoreBundle\Notifier\Notifier;
use Ferienpass\CoreBundle\Repository\UserRepository;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Uuid;
use Symfony\Contracts\Translation\TranslatorInterface;

final class LoginLinkTest extends TestCase
{
    public function testDoesNothingWhenUserNotFound(): void
    {
        $users = $this->createMock(UserRepository::class);
        $users->method('findOneBy')->willReturn(null);

        $notifier = $this->createMock(Notifier::class);
        $notifier->expects(self::never())->method('send');

        $handler = new LoginLink(
            $notifier,
            $users,
            $this->createMock(UserLoginLinkNotification::class),
            $this->createMock(TranslatorInterface::class)
        );
        $handler(new LoginLinkRequested(Uuid::v7()->toRfc4122(), 'https://example.com/login_link?hash=abc'), Uuid::v7());
    }
}
