HelpCommandTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. require_once __DIR__.'/../../../../bootstrap.php';
  10. use Symfony\Components\Console\Tester\CommandTester;
  11. use Symfony\Components\Console\Command\HelpCommand;
  12. use Symfony\Components\Console\Command\ListCommand;
  13. use Symfony\Components\Console\Application;
  14. $t = new LimeTest(4);
  15. // ->execute()
  16. $t->diag('->execute()');
  17. $command = new HelpCommand();
  18. $command->setCommand(new ListCommand());
  19. $commandTester = new CommandTester($command);
  20. $commandTester->execute(array());
  21. $t->like($commandTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given command');
  22. $commandTester->execute(array('--xml' => true));
  23. $t->like($commandTester->getDisplay(), '/<command/', '->execute() returns an XML help text if --xml is passed');
  24. $application = new Application();
  25. $commandTester = new CommandTester($application->getCommand('help'));
  26. $commandTester->execute(array('command_name' => 'list'));
  27. $t->like($commandTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given command');
  28. $commandTester->execute(array('command_name' => 'list', '--xml' => true));
  29. $t->like($commandTester->getDisplay(), '/<command/', '->execute() returns an XML help text if --xml is passed');