123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- declare(strict_types=1);
- namespace PhpCsFixer\Tests\Console\Output\Progress;
- use PhpCsFixer\Console\Output\OutputContext;
- use PhpCsFixer\Console\Output\Progress\DotsOutput;
- use PhpCsFixer\Console\Output\Progress\NullOutput;
- use PhpCsFixer\Console\Output\Progress\ProgressOutputFactory;
- use PhpCsFixer\Console\Output\Progress\ProgressOutputType;
- use PhpCsFixer\Tests\TestCase;
- use Symfony\Component\Console\Output\NullOutput as SymfonyNullOutput;
- final class ProgressOutputFactoryTest extends TestCase
- {
-
- public function testValidProcessOutputIsCreated(
- string $outputType,
- OutputContext $context,
- string $expectedOutputClass
- ): void {
-
- self::assertInstanceOf($expectedOutputClass, (new ProgressOutputFactory())->create($outputType, $context));
- }
-
- public static function provideValidProcessOutputIsCreatedCases(): iterable
- {
- $context = new OutputContext(new SymfonyNullOutput(), 100, 10);
- $nullContext = new OutputContext(null, 100, 10);
- yield 'none' => [ProgressOutputType::NONE, $context, NullOutput::class];
- yield 'dots' => [ProgressOutputType::DOTS, $context, DotsOutput::class];
- yield 'dots with null output' => [ProgressOutputType::DOTS, $nullContext, NullOutput::class];
- yield 'unsupported type with null output' => ['boom', $nullContext, NullOutput::class];
- }
- public function testExceptionIsThrownForUnsupportedProcessOutputType(): void
- {
- $this->expectException(\InvalidArgumentException::class);
- $outputContext = new OutputContext(new SymfonyNullOutput(), 100, 10);
-
- (new ProgressOutputFactory())->create('boom', $outputContext);
- }
- }
|