DescribeCommandTest.php 1.5 KB

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