<?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\Mailer\SentMessageListener;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\Mailer\Envelope;
use Symfony\Component\Mailer\Event\SentMessageEvent;
use Symfony\Component\Mailer\SentMessage;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;

final class SentMessageListenerTest extends TestCase
{
    public function testDoesNotLogNonNotificationEmail(): void
    {
        $logger = $this->createMock(LoggerInterface::class);
        $logger->expects(self::never())->method('info');

        $listener = new SentMessageListener($logger);

        $email = new Email()->from('from@example.com')->to('to@example.com')->text('Hello');
        $envelope = new Envelope(new Address('from@example.com'), [new Address('to@example.com')]);
        $sentMessage = new SentMessage($email, $envelope);

        $event = new SentMessageEvent($sentMessage);
        $listener($event);
    }
}
