本文整理汇总了PHP中Symfony\Component\Console\Application::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::get方法的具体用法?PHP Application::get怎么用?PHP Application::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Application
的用法示例。
在下文中一共展示了Application::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$application = new Application();
$application->add(new RepositoryTransferCommand($this->container));
$command = $application->get(RepositoryTransferCommand::COMMAND_NAME);
$this->commandTester = new CommandTester($command);
}
示例2: testValidCommands
public function testValidCommands()
{
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\GenerateDocumentsCommand', $this->cli->get('odm:generate:documents'));
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\GenerateHydratorsCommand', $this->cli->get('odm:generate:hydrators'));
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\GenerateProxiesCommand', $this->cli->get('odm:generate:proxies'));
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\GenerateRepositoriesCommand', $this->cli->get('odm:generate:repositories'));
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\QueryCommand', $this->cli->get('odm:query'));
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\Schema\\CreateCommand', $this->cli->get('odm:schema:create'));
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\Schema\\UpdateCommand', $this->cli->get('odm:schema:update'));
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\Tools\\Console\\Command\\Schema\\DropCommand', $this->cli->get('odm:schema:drop'));
}
示例3: setUp
public function setUp()
{
$application = new Application();
$application->add(new CreateOrganizationCommand());
$this->command = $application->get('swp:organization:create');
$this->question = $this->command->getHelper('question');
}
开发者ID:SuperdeskWebPublisher,项目名称:SWPMultiTenancyBundle,代码行数:7,代码来源:CreateOrganizationCommandTest.php
示例4: setUp
protected function setUp()
{
$application = new Application();
$application->add(new SearchCommand($this->container));
$command = $application->get(SearchCommand::COMMAND_NAME);
$this->commandTester = new CommandTester($command);
}
示例5: testExecute
/**
* @covers ::execute
*/
public function testExecute()
{
$client = new ClientMock();
$client->queueResponse('packagist/list.json')->queueResponse('packagist/list.json')->queueResponse('packagist/list.empty.json');
$command = new SearchCommand($client);
$console = new Application();
$console->add($command);
$tester = new CommandTester($console->get('search'));
$tester->execute([]);
$expected = <<<RESPONSE
Available Init Templates:
clippings/package-template
harp-orm/harp-template
openbuildings/jam-template
RESPONSE;
$this->assertEquals($expected, $tester->getDisplay());
$tester->execute(['filter' => 'clip']);
$expected = <<<RESPONSE
Available Init Templates:
clippings/package-template
RESPONSE;
$this->assertEquals($expected, $tester->getDisplay());
$expected = <<<RESPONSE
No templates found
RESPONSE;
$tester->execute([]);
$this->assertEquals($expected, $tester->getDisplay());
}
示例6: setUp
public function setUp()
{
$application = new Application();
$application->add(new CreateTenantCommand());
$this->command = $application->get('swp:tenant:create');
$this->question = $this->command->getHelper('question');
}
示例7: getCommandTester
protected function getCommandTester(Command $command, $name, $params = [])
{
$application = new Application();
$application->add($command);
$tester = new CommandTester($application->get($name));
$tester->execute(array_merge(['command' => $command->getName()], $params));
return $tester;
}
示例8: testExecuteForApplicationCommandWithXmlOption
public function testExecuteForApplicationCommandWithXmlOption()
{
$application = new Application();
$commandTester = new CommandTester($application->get('help'));
$commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
$this->assertContains('list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
}
示例9: testExecuteForApplicationCommandWithXmlOption
public function testExecuteForApplicationCommandWithXmlOption()
{
$application = new Application();
$commandTester = new CommandTester($application->get('help'));
$commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
$this->assertRegExp('/list \\[--xml\\] \\[--raw\\] \\[--format="\\.\\.\\."\\] \\[namespace\\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
}
示例10: get
/**
* @inheritdoc
*/
public function get($name)
{
$command = parent::get($name);
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->kernel->getContainer());
}
return $command;
}
示例11: testExecute
public function testExecute()
{
$application = new Application();
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getFullName()));
$this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
$commandTester->execute(array('command' => $command->getFullName(), '--xml' => true));
$this->assertRegExp('/<command id="list" namespace="_global" name="list">/', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed');
}
示例12: testExecuteListsCommandsWithRawOption
public function testExecuteListsCommandsWithRawOption()
{
$application = new Application();
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), '--raw' => true));
$output = <<<EOF
help Displays help for a command
list Lists commands
EOF;
$this->assertEquals($output, $commandTester->getDisplay(true));
}
示例13: testArrayCallbackSyntax
public function testArrayCallbackSyntax()
{
$console = new Application();
$console->add(new LlamaCommand('test:llama-command', null, array($this, 'simpleCallback')));
$this->assertTrue($console->has('test:llama-command'));
$command = $console->get('test:llama-command');
$this->assertInstanceOf('Beryllium\\Llama\\LlamaCommand', $command);
$input = new ArrayInput(array('test:llama-command'));
$output = new BufferedOutput();
$command->run($input, $output);
$this->assertSame("simple callback works\n", $output->fetch());
}
示例14: testExecuteListsCommandsWithNamespaceArgument
public function testExecuteListsCommandsWithNamespaceArgument()
{
require_once realpath(__DIR__ . '/../Fixtures/FooCommand.php');
$application = new Application();
$application->add(new \FooCommand());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true));
$output = <<<EOF
foo:bar The foo:bar command
EOF;
$this->assertEquals($output, $commandTester->getDisplay(true));
}
示例15: testExecuteCurrent
public function testExecuteCurrent()
{
$manifest = $this->createFile();
file_put_contents($manifest, '[]');
$command = new Command('upgrade', true);
$command->setManifestUri($manifest);
$app = new Application('Test', '1.0.0');
$app->getHelperSet()->set(new Helper());
$app->add($command);
$tester = new CommandTester($app->get('upgrade'));
$tester->execute(array('command' => 'upgrade'));
$this->assertRegExp('/Already up-to-date\\./', $tester->getDisplay());
}