Esempio n. 1
0
$t->is($application->getHelp(), file_get_contents($fixtures.'/application_gethelp.txt'), '->setHelp() returns a help message');

// ->getCommands()
$t->diag('->getCommands()');
$application = new Application();
$commands = $application->getCommands();
$t->is(get_class($commands['help']), 'Symfony\\Components\\Console\\Command\\HelpCommand', '->getCommands() returns the registered commands');

$application->addCommand(new FooCommand());
$commands = $application->getCommands('foo');
$t->is(count($commands), 1, '->getCommands() takes a namespace as its first argument');

// ->register()
$t->diag('->register()');
$application = new Application();
$command = $application->register('foo');
$t->is($command->getName(), 'foo', '->register() regiters a new command');

// ->addCommand() ->addCommands()
$t->diag('->addCommand() ->addCommands()');
$application = new Application();
$application->addCommand($foo = new FooCommand());
$commands = $application->getCommands();
$t->is($commands['foo:bar'], $foo, '->addCommand() registers a command');

$application = new Application();
$application->addCommands(array($foo = new FooCommand(), $foo1 = new Foo1Command()));
$commands = $application->getCommands();
$t->is(array($commands['foo:bar'], $commands['foo:bar1']), array($foo, $foo1), '->addCommands() registers an array of commands');

// ->hasCommand() ->getCommand()
Esempio n. 2
0
 public function testRegister()
 {
     $application = new Application();
     $command = $application->register('foo');
     $this->assertEquals('foo', $command->getName(), '->register() registers a new command');
 }
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

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

use Symfony\Components\Console\Application;
use Symfony\Components\Console\Output\Output;
use Symfony\Components\Console\Tester\ApplicationTester;

$t = new LimeTest(6);

$application = new Application();
$application->setAutoExit(false);
$application->register('foo')
  ->addArgument('command')
  ->addArgument('foo')
  ->setCode(function ($input, $output) { $output->writeln('foo'); })
;

$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foo', 'foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));

// ->run()
$t->diag('->run()');
$t->is($tester->getInput()->isInteractive(), false, '->execute() takes an interactive option');
$t->is($tester->getOutput()->isDecorated(), false, '->execute() takes a decorated option');
$t->is($tester->getOutput()->getVerbosity(), Output::VERBOSITY_VERBOSE, '->execute() takes a verbosity option');

// ->getInput()