<?php

declare(strict_types=1);

namespace App\Tests\Functional\Command;

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;

/**
 * @internal
 */
class MailSyncCommandTest extends KernelTestCase
{
    public function testCommandExitsSuccessWhenMailDisabled(): void
    {
        self::bootKernel();
        $application = new Application(self::$kernel);
        $command     = $application->find('app:mail:sync');
        $tester      = new CommandTester($command);

        $exitCode = $tester->execute([]);

        self::assertSame(0, $exitCode);
        self::assertStringContainsString('disabled', strtolower($tester->getDisplay()));
    }

    public function testCommandDryRunExitsSuccess(): void
    {
        self::bootKernel();
        $application = new Application(self::$kernel);
        $command     = $application->find('app:mail:sync');
        $tester      = new CommandTester($command);

        $exitCode = $tester->execute(['--dry-run' => true]);

        self::assertSame(0, $exitCode);
    }
}
