use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandCompletionTester;
use Symfony\Component\Console\Tester\CommandTester;
class ListCommandTest extends TestCase
{ public function testExecuteListsCommands() { $application =
new Application();
$commandTester =
new CommandTester($command =
$application->
get('list'
));
$commandTester->
execute(['command' =>
$command->
getName()],
['decorated' => false
]);
$this->
assertMatchesRegularExpression('/help\s{2,}Display help for a command/',
$commandTester->
getDisplay(), '->execute() returns a list of available commands'
);
} public function testExecuteListsCommandsWithXmlOption() { $application =
new Application();
$commandTester =
new CommandTester($command =
$application->
get('list'
));
$commandTester->
execute(['command' =>
$command->
getName(), '--format' => 'xml'
]);
$this->
assertMatchesRegularExpression('/<command id="list" name="list" hidden="0">/',
$commandTester->
getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed'
);
}