Exemplo n.º 1
0
 public function testExecute()
 {
     $command = new HelpCommand();
     $command->setCommand(new ListCommand());
     $commandTester = new CommandTester($command);
     $commandTester->execute(array());
     $this->assertRegExp('/list \\[--xml\\] \\[namespace\\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
     $commandTester->execute(array('--xml' => true));
     $this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
     $application = new Application();
     $commandTester = new CommandTester($application->getCommand('help'));
     $commandTester->execute(array('command_name' => 'list'));
     $this->assertRegExp('/list \\[--xml\\] \\[namespace\\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
     $commandTester->execute(array('command_name' => 'list', '--xml' => true));
     $this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
 }
Exemplo n.º 2
0
 * file that was distributed with this source code.
 */

require_once __DIR__.'/../../../../bootstrap.php';

use Symfony\Components\Console\Tester\CommandTester;
use Symfony\Components\Console\Command\HelpCommand;
use Symfony\Components\Console\Command\ListCommand;
use Symfony\Components\Console\Application;

$t = new LimeTest(4);

// ->execute()
$t->diag('->execute()');

$command = new HelpCommand();
$command->setCommand(new ListCommand());

$commandTester = new CommandTester($command);
$commandTester->execute(array());
$t->like($commandTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given command');

$commandTester->execute(array('--xml' => true));
$t->like($commandTester->getDisplay(), '/<command/', '->execute() returns an XML help text if --xml is passed');

$application = new Application();
$commandTester = new CommandTester($application->getCommand('help'));
$commandTester->execute(array('command_name' => 'list'));
$t->like($commandTester->getDisplay(), '/list \[--xml\] \[namespace\]/', '->execute() returns a text help for the given command');

$commandTester->execute(array('command_name' => 'list', '--xml' => true));