CheckCommandTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Console\Command;
  13. use PhpCsFixer\Console\Application;
  14. use PhpCsFixer\Console\Command\CheckCommand;
  15. use PhpCsFixer\Tests\TestCase;
  16. use PhpCsFixer\ToolInfo;
  17. use Symfony\Component\Console\Output\OutputInterface;
  18. use Symfony\Component\Console\Tester\CommandTester;
  19. /**
  20. * @internal
  21. *
  22. * @covers \PhpCsFixer\Console\Command\CheckCommand
  23. */
  24. final class CheckCommandTest extends TestCase
  25. {
  26. /**
  27. * This test ensures that `--dry-run` option is not available in `check` command,
  28. * because this command is a proxy for `fix` command which always set `--dry-run` during proxying,
  29. * so it does not make sense to provide this option again.
  30. */
  31. public function testDryRunModeIsUnavailable(): void
  32. {
  33. $application = new Application();
  34. $application->add(new CheckCommand(new ToolInfo()));
  35. $command = $application->find('check');
  36. $commandTester = new CommandTester($command);
  37. $commandTester->execute(
  38. [
  39. 'command' => $command->getName(),
  40. '--help' => true,
  41. 'path' => [__FILE__], // just to get rid of Finder error
  42. ],
  43. [
  44. 'interactive' => false,
  45. 'decorated' => false,
  46. 'verbosity' => OutputInterface::VERBOSITY_DEBUG,
  47. ]
  48. );
  49. self::assertStringNotContainsString(
  50. '--dry-run',
  51. $commandTester->getDisplay()
  52. );
  53. }
  54. }