Skip to content

Commit

Permalink
trivial test to ensure command does not crash
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Apr 18, 2021
1 parent c3e219b commit ed48122
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Console/Command/ListFilesCommandTest.php
Expand Up @@ -35,6 +35,7 @@ public function testListWithConfig()
// make the test also work on windows
$expectedPath = str_replace('/', \DIRECTORY_SEPARATOR, $expectedPath);

static::assertSame(0, $commandTester->getStatusCode());
static::assertSame(escapeshellarg($expectedPath).PHP_EOL, $commandTester->getDisplay());
}

Expand Down
53 changes: 53 additions & 0 deletions tests/Console/Command/ListSetsCommandTest.php
@@ -0,0 +1,53 @@
<?php

/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace PhpCsFixer\Tests\Console\Command;

use PhpCsFixer\Console\Application;
use PhpCsFixer\Console\Command\ListSetsCommand;
use PhpCsFixer\Tests\TestCase;
use PhpCsFixer\ToolInfo;
use Symfony\Component\Console\Tester\CommandTester;

/**
* @internal
*
* @covers \PhpCsFixer\Console\Command\ListSetsCommand
*/
final class ListSetsCommandTest extends TestCase
{
public function testListWithConfig()
{
$commandTester = $this->doTestExecute([]);

$resultStart = ' 1) @DoctrineAnnotation
Rules covering Doctrine annotations';
static::assertStringStartsWith($resultStart, $commandTester->getDisplay());
static::assertSame(0, $commandTester->getStatusCode());
}

/**
* @return CommandTester
*/
private function doTestExecute(array $arguments)
{
$application = new Application();
$application->add(new ListSetsCommand());

$command = $application->find('list-sets');
$commandTester = new CommandTester($command);

$commandTester->execute($arguments);

return $commandTester;
}
}

0 comments on commit ed48122

Please sign in to comment.