Skip to content

Commit 5830589

Browse files
committed
minor PHP-CS-Fixer#4471 ReadmeCommandTest - use CommandTester (kubawerlos)
This PR was merged into the 2.12 branch. Discussion ---------- ReadmeCommandTest - use CommandTester Fixes [Travis](https://travis-ci.org/FriendsOfPHP/PHP-CS-Fixer/jobs/561270967#L966) on PHP `7.4snapshot` by modernizing `ReadmeCommand` test. Commits ------- dbe4ed1 Test ReadmeCommand with CommandTester
2 parents c523dc1 + dbe4ed1 commit 5830589

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

tests/Console/Command/ReadmeCommandTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
use PhpCsFixer\Console\Application;
1616
use PhpCsFixer\Tests\TestCase;
17-
use Symfony\Component\Console\Input\ArrayInput;
18-
use Symfony\Component\Console\Output\BufferedOutput;
19-
use Symfony\Component\Console\Output\OutputInterface;
17+
use Symfony\Component\Console\Tester\CommandTester;
2018

2119
/**
2220
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
@@ -36,15 +34,12 @@ public function testIfReadmeFileIsCorrect()
3634
$fileContent = file_get_contents($readmeFile);
3735
static::assertInternalType('string', $fileContent, sprintf('Failed to get content of "%s"', $readmeFile));
3836

39-
$app = new Application();
40-
$input = new ArrayInput(['readme']);
37+
$application = new Application();
4138

42-
$output = new BufferedOutput();
43-
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
44-
$output->setDecorated(false);
39+
$commandTester = new CommandTester($application->get('readme'));
4540

46-
$exitCode = $app->get('readme')->run($input, $output);
47-
$output = $output->fetch();
41+
$exitCode = $commandTester->execute([]);
42+
$output = $commandTester->getDisplay();
4843
// normalize line breaks, these are not important for the tests
4944
$output = str_replace(PHP_EOL, "\n", $output);
5045

0 commit comments

Comments
 (0)