<?php

declare(strict_types=1);

namespace App\Tests\Functional\Controller\Mail;

use App\Module\Core\Domain\Entity\User;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

/**
 * @internal
 */
class MailMessagesControllerTest extends WebTestCase
{
    public function testGetMessageDetailReturns401WhenNotAuthenticated(): void
    {
        $client = static::createClient();
        $client->request('GET', '/api/mail/messages/999');

        self::assertResponseStatusCodeSame(401);
    }

    public function testGetMessageDetailReturns404WhenMessageNotFound(): void
    {
        $client    = static::createClient();
        $container = static::getContainer();
        $em        = $container->get('doctrine.orm.entity_manager');

        $user = $em->getRepository(User::class)->findOneBy(['username' => 'alice']);
        $client->loginUser($user);
        $client->request('GET', '/api/mail/messages/99999');

        self::assertResponseStatusCodeSame(404);
    }
}
