ListCommandTest.php 1.1 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Console\Command;
  11. use Symfony\Component\Console\Tester\CommandTester;
  12. use Symfony\Component\Console\Application;
  13. class ListCommandTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testExecute()
  16. {
  17. $application = new Application();
  18. $commandTester = new CommandTester($command = $application->get('list'));
  19. $commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
  20. $this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
  21. $commandTester->execute(array('command' => $command->getName(), '--xml' => true));
  22. $this->assertRegExp('/<command id="list" name="list">/', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed');
  23. }
  24. }