TYPO3  7.6
HelpCommandTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Symfony\Component\Console\Tests\Command;
13 
18 
19 class HelpCommandTest extends \PHPUnit_Framework_TestCase
20 {
21  public function testExecuteForCommandAlias()
22  {
23  $command = new HelpCommand();
24  $command->setApplication(new Application());
25  $commandTester = new CommandTester($command);
26  $commandTester->execute(array('command_name' => 'li'), array('decorated' => false));
27  $this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
28  $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
29  $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
30  }
31 
32  public function testExecuteForCommand()
33  {
34  $command = new HelpCommand();
35  $commandTester = new CommandTester($command);
36  $command->setCommand(new ListCommand());
37  $commandTester->execute(array(), array('decorated' => false));
38  $this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
39  $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
40  $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
41  }
42 
44  {
45  $command = new HelpCommand();
46  $commandTester = new CommandTester($command);
47  $command->setCommand(new ListCommand());
48  $commandTester->execute(array('--format' => 'xml'));
49  $this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
50  }
51 
53  {
54  $application = new Application();
55  $commandTester = new CommandTester($application->get('help'));
56  $commandTester->execute(array('command_name' => 'list'));
57  $this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
58  $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
59  $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
60  }
61 
63  {
64  $application = new Application();
65  $commandTester = new CommandTester($application->get('help'));
66  $commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
67  $this->assertContains('list [--xml] [--raw] [--format FORMAT] [--] [&lt;namespace&gt;]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
68  $this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
69  }
70 }