<?php

declare(strict_types=1);

namespace CpCreation\AltchaBundle\Tests\PublicApi;

use CpCreation\AltchaBundle\Command\SynchronizeScopesCommand;
use CpCreation\AltchaBundle\Scope\ScopeRegistry;
use CpCreation\AltchaBundle\Tests\Double\FakeAltchaServiceClient;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;

final class SynchronizeScopesCommandTest extends TestCase
{
    public function testCommandIsDryRunByDefaultAndCanBeAppliedExplicitly(): void
    {
        $command = new SynchronizeScopesCommand(
            new FakeAltchaServiceClient(),
            new ScopeRegistry(['site.contact' => 'Contact']),
        );
        $tester = new CommandTester($command);

        self::assertSame(Command::SUCCESS, $tester->execute([]));
        self::assertStringContainsString('DRY-RUN', $tester->getDisplay());

        self::assertSame(Command::SUCCESS, $tester->execute(['--apply' => true]));
        self::assertStringContainsString('APPLY', $tester->getDisplay());
    }
}
