HelpTaskTest.php 1.4 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\CLI\Tester\TaskTester;
  11. use Symfony\Components\CLI\Task\HelpTask;
  12. use Symfony\Components\CLI\Task\ListTask;
  13. use Symfony\Components\CLI\Application;
  14. $t = new LimeTest(4);
  15. // ->execute()
  16. $t->diag('->execute()');
  17. $task = new HelpTask();
  18. $task->setTask(new ListTask());
  19. $taskTester = new TaskTester($task);
  20. $taskTester->execute(array());
  21. $t->like($taskTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given task');
  22. $taskTester->execute(array('--xml' => true));
  23. $t->like($taskTester->getDisplay(), '/<task/', '->execute() returns an XML help text if --xml is passed');
  24. $application = new Application();
  25. $taskTester = new TaskTester($application->getTask('help'));
  26. $taskTester->execute(array('task_name' => 'list'));
  27. $t->like($taskTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given task');
  28. $taskTester->execute(array('task_name' => 'list', '--xml' => true));
  29. $t->like($taskTester->getDisplay(), '/<task/', '->execute() returns an XML help text if --xml is passed');