DescribeCommandTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 legacy
  24. * @group auto-review
  25. * @group covers-nothing
  26. */
  27. final class DescribeCommandTest extends TestCase
  28. {
  29. /**
  30. * @dataProvider provideDescribeCommandCases
  31. */
  32. public function testDescribeCommand(FixerFactory $factory, string $fixerName): void
  33. {
  34. // @TODO 4.0 Remove this expectation
  35. $this->expectDeprecation('Rule set "@PER" is deprecated. Use "@PER-CS" instead.');
  36. $this->expectDeprecation('Rule set "@PER:risky" is deprecated. Use "@PER-CS:risky" instead.');
  37. $command = new DescribeCommand($factory);
  38. $application = new Application();
  39. $application->add($command);
  40. $commandTester = new CommandTester($command);
  41. $commandTester->execute([
  42. 'command' => $command->getName(),
  43. 'name' => $fixerName,
  44. ]);
  45. self::assertSame(0, $commandTester->getStatusCode());
  46. }
  47. public static function provideDescribeCommandCases(): iterable
  48. {
  49. $factory = new FixerFactory();
  50. $factory->registerBuiltInFixers();
  51. foreach ($factory->getFixers() as $fixer) {
  52. yield [$factory, $fixer->getName()];
  53. }
  54. }
  55. }