DescribeCommandTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\AutoReview;
  13. use PhpCsFixer\Console\Application;
  14. use PhpCsFixer\Console\Command\DescribeCommand;
  15. use PhpCsFixer\FixerFactory;
  16. use PhpCsFixer\Tests\TestCase;
  17. use Symfony\Component\Console\Tester\CommandTester;
  18. /**
  19. * @internal
  20. *
  21. * @coversNothing
  22. *
  23. * @group auto-review
  24. * @group covers-nothing
  25. */
  26. final class DescribeCommandTest extends TestCase
  27. {
  28. /**
  29. * @dataProvider provideDescribeCommandCases
  30. */
  31. public function testDescribeCommand(FixerFactory $factory, string $fixerName): void
  32. {
  33. $command = new DescribeCommand($factory);
  34. $application = new Application();
  35. $application->add($command);
  36. $commandTester = new CommandTester($command);
  37. $commandTester->execute([
  38. 'command' => $command->getName(),
  39. 'name' => $fixerName,
  40. ]);
  41. self::assertSame(0, $commandTester->getStatusCode());
  42. }
  43. public static function provideDescribeCommandCases(): iterable
  44. {
  45. $factory = new FixerFactory();
  46. $factory->registerBuiltInFixers();
  47. foreach ($factory->getFixers() as $fixer) {
  48. yield [$factory, $fixer->getName()];
  49. }
  50. }
  51. }