4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Console\Tests\Command;
14 use Symfony\Component\Console\Tester\CommandTester;
15 use Symfony\Component\Console\Application;
17 class ListCommandTest extends \PHPUnit_Framework_TestCase
19 public function testExecute()
21 $application = new Application();
23 $commandTester = new CommandTester($command = $application->get('list'));
24 $commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
25 $this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
27 $commandTester->execute(array('command' => $command->getName(), '--xml' => true));
28 $this->assertRegExp('/<command id="list" name="list">/', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed');
30 $commandTester->execute(array('command' => $command->getName(), '--raw' => true));
32 help Displays help for a command
36 $this->assertEquals(str_replace("\n", PHP_EOL, $output), $commandTester->getDisplay(), 'boo');