Exemplo n.º 1
0
try {
    $application->getCommand('foofoo');
    $t->fail('->getCommand() throws an \\InvalidArgumentException if the command does not exist');
} catch (\InvalidArgumentException $e) {
    $t->pass('->getCommand() throws an \\InvalidArgumentException if the command does not exist');
}
class TestApplication extends Application
{
    public function setWantHelps()
    {
        $this->wantHelps = true;
    }
}
$application = new TestApplication();
$application->addCommand($foo = new FooCommand());
$application->setWantHelps();
$command = $application->getCommand('foo:bar');
$t->is(get_class($command), 'Symfony\\Components\\CLI\\Command\\HelpCommand', '->getCommand() returns the help command if --help is provided as the input');
// ->getNamespaces()
$t->diag('->getNamespaces()');
$application = new TestApplication();
$application->addCommand(new FooCommand());
$application->addCommand(new Foo1Command());
$t->is($application->getNamespaces(), array('foo'), '->getNamespaces() returns an array of unique used namespaces');
// ->findNamespace()
$t->diag('->findNamespace()');
$application = new TestApplication();
$application->addCommand(new FooCommand());
$t->is($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists');
$t->is($application->findNamespace('f'), 'foo', '->findNamespace() finds a namespace given an abbreviation');
$application->addCommand(new Foo2Command());