HelpCommandTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2023 Justin Hileman
  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 Psy\Test\Command;
  11. use Psy\Command\HelpCommand;
  12. use Psy\Shell;
  13. use Symfony\Component\Console\Tester\CommandTester;
  14. /**
  15. * @group isolation-fail
  16. */
  17. class HelpCommandTest extends \Psy\Test\TestCase
  18. {
  19. public function testExecute()
  20. {
  21. $shell = new Shell();
  22. $command = new HelpCommand();
  23. $command->setApplication($shell);
  24. $tester = new CommandTester($command);
  25. $tester->execute([]);
  26. $this->assertStringContainsString('Show a list of commands. Type `help [foo]` for information about [foo].', $tester->getDisplay());
  27. foreach ($shell->all() as $command) {
  28. $pattern = \sprintf('/^\s*%s/m', \preg_quote($command->getName()));
  29. $this->assertMatchesRegularExpression($pattern, $tester->getDisplay());
  30. }
  31. $this->assertStringContainsString('End the current session and return to caller.', $tester->getDisplay());
  32. $this->assertStringContainsString('Aliases: quit, q', $tester->getDisplay());
  33. }
  34. }