DocumentationCommandTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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\DocumentationCommand;
  15. use PhpCsFixer\Tests\TestCase;
  16. use Symfony\Component\Console\Output\OutputInterface;
  17. use Symfony\Component\Console\Tester\CommandTester;
  18. use Symfony\Component\Filesystem\Filesystem;
  19. /**
  20. * @internal
  21. *
  22. * @covers \PhpCsFixer\Console\Command\DocumentationCommand
  23. */
  24. final class DocumentationCommandTest extends TestCase
  25. {
  26. public function testGeneratingDocumentation(): void
  27. {
  28. $filesystem = $this->createFilesystemDouble();
  29. $application = new Application();
  30. $application->add(new DocumentationCommand($filesystem));
  31. $command = $application->find('documentation');
  32. $commandTester = new CommandTester($command);
  33. $commandTester->execute(
  34. [
  35. 'command' => $command->getName(),
  36. ],
  37. [
  38. 'interactive' => false,
  39. 'decorated' => false,
  40. 'verbosity' => OutputInterface::VERBOSITY_DEBUG,
  41. ],
  42. );
  43. self::assertStringContainsString(
  44. 'Docs updated.',
  45. $commandTester->getDisplay(),
  46. );
  47. }
  48. private function createFilesystemDouble(): Filesystem
  49. {
  50. return new class extends Filesystem {
  51. public function dumpFile(string $filename, $content): void {}
  52. /** @phpstan-ignore-next-line */
  53. public function remove($files): void {}
  54. };
  55. }
  56. }