DescribeCommandTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. */
  23. final class DescribeCommandTest extends TestCase
  24. {
  25. /**
  26. * @dataProvider provideDescribeCommandCases
  27. *
  28. * @param FixerFactory $factory
  29. * @param string $fixerName
  30. */
  31. public function testDescribeCommand(FixerFactory $factory, $fixerName)
  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. $this->assertSame(0, $commandTester->getStatusCode());
  42. }
  43. public function provideDescribeCommandCases()
  44. {
  45. $factory = new FixerFactory();
  46. $factory->registerBuiltInFixers();
  47. $cases = [];
  48. foreach ($factory->getFixers() as $fixer) {
  49. $cases[] = [$factory, $fixer->getName()];
  50. }
  51. return $cases;
  52. }
  53. }