<?php

declare(strict_types=1);

namespace Ferienpass\AdminBundle\Tests\NotificationHandler;

use Ferienpass\AdminBundle\Message\PasswordLinkCreated;
use Ferienpass\AdminBundle\NotificationHandler\PasswordLink;
use Ferienpass\CoreBundle\Entity\User;
use Ferienpass\CoreBundle\Notifier\Notifier;
use Ferienpass\CoreBundle\Repository\UserRepository;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Uid\Uuid;

final class PasswordLinkTest extends TestCase
{
    public function testDoesNothingWhenNotifierReturnsNull(): void
    {
        $user = new User();
        $user->setEmail('user@example.com');

        $users = $this->createMock(UserRepository::class);
        $users->method('findOneBy')->willReturn($user);

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

        $handler = new PasswordLink(
            $notifier,
            $users,
            $this->createMock(UrlGeneratorInterface::class)
        );
        $handler(new PasswordLinkCreated(Uuid::v7()->toRfc4122(), 'my-token'), Uuid::v7());
    }
}
